Jump to content

Select Check Box


unemployment

Recommended Posts

This fails on me.  Firebug says msg is undefined.

 

function selectone () {
var msg = document.getElementsByName('pm');
var i = 0;

for(i; i < msg.elements.length; i++)
{
	if(msg.elements[i].checked === checked)
	{
		document.getElementById('multiple_action').disabled = false;
		document.getElementById('drop_button').setAttribute("class", "drop_button");
	}
	else
	{
		document.getElementById('multiple_action').disabled = true;
		document.getElementById('drop_button').setAttribute("class", "drop_button disabled");
	}
}
}

Link to comment
Share on other sites

Can you post html or provide a url?

 

HTMl below

 

<form method="get" id="pm" name="pm" onsubmit="return false;">
     <table class="messages">
          <tr>
               <td class="box_column">
                    <label><input type="checkbox" name="pmcheckbox" onclick="selectone();" value="pm<?php echo $message['message_id']; ?>" /></label>
               </td>
          </tr>
</form>

Link to comment
Share on other sites

This looks like you have more than one checkbox. I think you should send the id of the ckbox to the function. And msg is empty.

 

Would document.getElementsByTagName("INPUT"); work better for you?

 

P.S.  you don't have an id for any of the checkboxes.

 

Is this what you meant?  I added an id to the checkbox of msgcheckbox.

 

function selectone () {
var msg = document.getElementsById('pm');
var i = 0;

for(i; i < msg.elements.length; i++)
{
	if(msg.elements[i].checked == true)
	{
		document.getElementById('multiple_action').disabled = false;
		document.getElementById('drop_button').setAttribute("class", "drop_button");
	}
	else
	{
		document.getElementById('multiple_action').disabled = true;
		document.getElementById('drop_button').setAttribute("class", "drop_button disabled");
	}
}
}

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.