Jump to content

PHP / Javascript... Simple Question Really..


Chud37

Recommended Posts

Hello,

 

I have a form generated by mySQL and PHP, and inside the form (named 'UpdateDB') each line has checkboxes, like so:

 

<input type="checkbox" name="checkbox[]" value="96" onclick="highlight(this,'check_96')">

 

The onclick is to highlight the row, that works fine.  However, I wrote a javascript function that toggles the select all the checkboxes or none.  This is done by an image:

 

<img src="img/select.png" align="top">
<a href="#" onClick="togBox('updateDB');"><img src="img/all.png" name="listToggle" align="top"></a>

 

Easy, right? So heres the Javascript function that the above image (the 'none' part) links to:

 

function togBox(form) 
{	var myForm = document.forms[form];
	document.listToggle.src=='http://gospeltruth.tv/admin/img/all.png' ? toggle = true : toggle = false;
	(toggle) ? document.listToggle.src='img/none.png' : document.listToggle.src='img/all.png';
	for( var i=0; i < myForm.length; i++ ) 
	{ 
		(toggle) ? myForm.elements[i].checked = 'checked' : myForm.elements[i].checked = '';
	}
}

 

Its a brilliant function if I do say so myself, and this is what I dont get: yesterday, it was working fine, today, its not working at all.  The image changes, but IE flags up the 'myForm.length' as an error.

 

How was it working 2 days ago and not today, when I havent touched it? Can anybody advise why its not currently working?

 

Thanks for your help,

 

~Chud37

Link to comment
https://forums.phpfreaks.com/topic/246475-php-javascript-simple-question-really/
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.