#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2001
    Location
    New Zealand
    Posts
    167
    Rep Power
    14

    Question drowning in javascript...


    Hi guys,

    I've just downloaded this php-based chat program. However it's giving me some javascript errors and, since I'm trying to understand how the whole enchilada works, I took a peek at the source code.

    It's kind of complicated... anyone got any bright ideas on even what the constructs used here mean? For example:

    function sendMessage(name) {
    if (document.all) {
    top.wIn.document.all['form1'].txt.value="/msg "+name+' ';
    } else {
    top.wIn.document.form1.txt.value="/msg "+name+' ';
    }
    setFocus();
    }

    Is this javascript? (it's not specified, but it gave me a javascript error, so I'm assuming...)

    Here's some more of the enfant terrible:

    <script>
    function doSubmit() {
    if (document.all) {
    top.wSend.document.all['form2'].txt.value=escape(document.all['form1'].txt.value);
    top.wSend.document.all['form2'].submit();
    document.all['form1'].txt.value='';
    } else {
    top.wSend.document.form2.txt.value=escape(document.form1.txt.value);
    top.wSend.document.form2.submit();
    document.form1.txt.value='';
    }

    return false;
    }

    function setFocus() {
    if (document.all) {
    document.all['form1'].txt.focus();
    } else {
    document.form1.txt.focus();
    }
    }

    </script>

    What can I say?

    Any help appreciated!

    Jen
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2001
    Location
    New York
    Posts
    122
    Rep Power
    14
    Jen:

    Without seeing the "whole enchilada" and knowing what kind of errors are being generated, I don't know how much help I can offer. I've included a few comments that might help:

    Yes, it's Javascript.

    The code is expecting to operate in a html frameset, with two frames named "wIn" and "wSend".

    "wIn" should contain a form named "form1" and "wSend" should contain a form named "form2".

    Both forms have text fields named "txt".

    I don't know what else to tell you. Let me know what the error messages are (and when they occur) and send along the relevant code, if you need more help.

    Good luck.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2001
    Location
    Toronto, Ontario, Canada
    Posts
    631
    Rep Power
    14
    Without seeing the errors, the most likely problem is that you dont have forms named form1 and form2, and an input in each named txt.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2001
    Location
    New Zealand
    Posts
    167
    Rep Power
    14

    thanks...


    Thanks for the help...

    For some reason, when I changed the name of the database the php was trying to contact, the javascript errors went away. Now I'm REALLY confused! how does a database connection error disrupt the client-side script? The php wasn't writing any elements to the page or anything, it was just doing an insert AFTER all the javascript etc had run.

    Very strange!

    Anyway, thanks for the deconstructs, I always freak when I see these big blocks of script!

    Jen

IMN logo majestic logo threadwatch logo seochat tools logo