Results 1 to 4 of 4

Thread: Fix this nasty looking php/javascript code

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2006
    Location
    From the UK
    Posts
    422

    Question Fix this nasty looking php/javascript code

    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!

    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!!!

  2. #2
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Fix this nasty looking php/javascript code

    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.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2006
    Location
    From the UK
    Posts
    422

    Re: Fix this nasty looking php/javascript code

    Ah, ok visualAd, I will take note now - what is the correct method please?

  4. #4
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Fix this nasty looking php/javascript code

    Take away all the echo statements and you can use single or double quotes as you wish.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width