abhi10kumar Posted May 23, 2011 Share Posted May 23, 2011 I am passing value to AJAX function, but always shows undefined.. It works fine two days ago, but not today.. Checkbox <input type="checkbox" onclick="disablebatch(); selectinactivecourse(this.checked); " id="inactive_check" name="inactive_check" <?php if(isset($_POST['inactive_check'])) echo "checked";?>> Combobox <select id="course" name="course" style="width:145px" onchange="selectBatch1(this.value, document.myform.inactive_batch.value);"> // Where I am passing Checkbox's value <select id="course" name="course" style="width:145px" onchange="selectBatch1(this.value, document.myform.inactive_batch.checked);"> // Also not working function disablebatch() { if(document.myform.inactive_check.checked) { document.myform.inactive_batch.value=1; document.myform.inactive_batch.disabled=true; document.myform.batch.disabled=true; alert(document.myform.inactive_batch.value); } else { document.myform.inactive_batch.value=0; document.myform.inactive_batch.disabled=false; document.myform.batch.disabled=false; alert(document.myform.inactive_batch.value); } } function selectBatch1(str, str1) { var v=str1; // str1 value is undefined xmlhttp1=GetXmlHttpObject1(); if (xmlhttp1==null) { alert ("Your browser does not support AJAX!"); return; } var url="selectBatch.php"; url=url+"?c="+str; url=url+"&action=misrpt"; if(v==undefined || v==true) url=url+"&val=0"; else url=url+"&val=1"; xmlhttp1.onreadystatechange=stateChanged1; xmlhttp1.open("GET",url,true); xmlhttp1.send(null); } Quote Link to comment Share on other sites More sharing options...
requinix Posted May 23, 2011 Share Posted May 23, 2011 Do inactive_check and inactive_batch refer to two different form fields? I can't tell if they're supposed to or not. Quote Link to comment Share on other sites More sharing options...
Psycho Posted May 23, 2011 Share Posted May 23, 2011 Um, you posted this: <select id="course" name="course" style="width:145px" onchange="selectBatch1(this.value, document.myform.inactive_batch.value);"> // Where I am passing Checkbox's value And that WOULD pass the value of the checkbox - if the checkbox actually had a value! Checkbox <input type="checkbox" onclick="disablebatch(); selectinactivecourse(this.checked); " id="inactive_check" name="inactive_check" <?php if(isset($_POST['inactive_check'])) echo "checked";?>> There is no value parameter for that checkbox!!! Looking at the function being called and how that "value" is used I think you meant to pass the checked state of the checkbox - not the value. By the way, why would you pass a variable to a function as str1 only to then to use that value to define another variable "v"? If you want the value in the variable v, then just use that in the function parameters. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.