Question

I want to pass a value as an argument of a function. The function is defined on onchange() of a text field. I am using the following code..I use zend form to create the element.

$filedName = "cust_attr_".($i+1);
$fieldArr[$i]       =   $this->createElement('Text',$filedName)
-> setAttrib('class','k-textbox float_left input_width_295 k-invalid')
-> setAttrib('onchange','validateDataType('.$customerAttributes[$i]['data_type'].')')
-> setAttrib('maxlength','14')
-> setAttrib('tabindex',(++$tabStart));

And when i run the code i am getting the value as the argument of function..Like

onchange="validateDataType(A)"

But i am getting an error Uncaught ReferenceError: A is not defined

How to solve this???

Was it helpful?

Solution

"A" should be passed as a string. Without the quotes it looks for A as an object.

-> setAttrib('onchange','validateDataType("'.$customerAttributes[$i]['data_type'].'")')

You will need to change onchange="validateDataType(A)" to single quotes... onchange='validateDataType("A")'

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top