Jump to content

PHP / Javascript... Simple Question Really..


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

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.