简体   繁体   中英

Why is my javascript parameter undefined?

I have the following function call:

    var id = $(this).attr("id");
    var style = $.trim($(this).find(".tdStyle").html());
    var qtyOnHand = $.trim($(this).find(".tdQtyOnHand").html());
    var PlantID = $.trim($(this).find(".tdPlantID").html());
    var Size = $.trim($(this).find(".tdSize").html());

    dialogOpen(id, style, qtyOnHand, $(this), Size);

I am trying to pass multiple values into my dialogOpen function by grabbing values from various elements. Every value is works fine in my dialogOpen function shown below with the exception of the last one _Size. I test the value of _Size before I get to dialogOpen with the following:

var _Size = ($.trim($(this).find(".tdSize").html())); 
console.log(_Size);

console.log shows 2.378

Here is the beginning of my code for my function where I get the undefined (on xSize):

function dialogOpen(ID, style, QtyOnHand, row, PlantID, xSize) 
{
debugger;
console.log(xSize);
$('#dialogForm').dialog({
title: 'Enter Quantity',
height: 200,

You're only sending 5 arguments. Probably just a mistake. Change this:

dialogOpen($(this).attr("id"), $.trim($(this).find(".tdStyle").html()), $.trim($(this).find(".tdQtyOnHand").html()), $(this), $.trim($(this).find(".tdPlantID").html(), _Size));

To this:

dialogOpen($(this).attr("id"), $.trim($(this).find(".tdStyle").html()), $.trim($(this).find(".tdQtyOnHand").html()), $(this), $.trim($(this).find(".tdPlantID").html()), _Size);

There are six parameters, and only five values in the call.

You have placed the parentheses wrong for the second to last value, so the two last values are inside a parenthesis with the comma operator between them.

You have:

$.trim($(this).find(".tdPlantID").html(), _Size)

but you should have:

$.trim($(this).find(".tdPlantID").html()), _Size

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM