Jump to content

Checkbox's value is not passing correctly..


abhi10kumar

Recommended Posts

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);

}

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.