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
https://forums.phpfreaks.com/topic/226098-select-check-box/
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
https://forums.phpfreaks.com/topic/226098-select-check-box/#findComment-1167398
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
https://forums.phpfreaks.com/topic/226098-select-check-box/#findComment-1167464
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.