javascript error with php variable passing in codeigniter
815
function something(frm,i){
//var ch=frm.outof1.value;
for(var j=1;j<=i;j++)
{
//var b="outof" + j;
alert(frm.outof+j.value);
}
//alert("outof" + i);
return false;
}
$js='onClick="something(this.form,\''. $ii .'\')"';
echo form_button('mybutton', 'Click Me', $js);
and getting output NAN where in html this is // echo form_input('outof'.$i,''); // the form input.
Answer
Solution:
First, you will want to make sure the passed
$ii
is made into the correct type (not a string) by usingparseInt
. Then you construct the form input name by concatenating'outof'
and the number before evaluating.value
.Answer
Solution:
Most likely, you're trying to sum up strings, and not integers