PDA

Click to See Complete Forum and Search --> : Fix this nasty looking php/javascript code


wwwfilmfilercom
Aug 31st, 2008, 03:39 PM
Hi,

I really need to help fixing this horrible piece of code which is all over the place. All it does is run a javascript function to check/uncheck my boxes on my form.

However, because the js quotes need to be single, and the echo quotes are double I've just made it into this crazy chunk of code!

//SHOWS THE CHECK ALL/UNCHECK ALL BOXES
echo '</table><input type="button" onclick="SetAllCheckBoxes(';
echo "'killform', 'killed[]', true);";
echo '" value="Select all" /><br /><br /><input type="button" onclick="SetAllCheckBoxes(';
echo "'killform', 'killed[]', false);";
echo '" value="Deselect all" /><br /><br /><input type="submit" name="kill" value="Kill" /></form>';

I agree, it looks terrible.

Ideally, it would be great if I could have it all in a link - such as a href=javascript... etc.

How can I clean this up?? Thanks for any help!!!:thumb:

visualAd
Aug 31st, 2008, 04:24 PM
I have mentioned many many times, that you should not use echo to output HTML. It is clear that my efforts have been in vain :( If you take my advice then the issue you will having will not arise.

wwwfilmfilercom
Sep 1st, 2008, 02:44 AM
Ah, ok visualAd, I will take note now - what is the correct method please?

visualAd
Sep 1st, 2008, 03:21 AM
Take away all the echo statements and you can use single or double quotes as you wish.