Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi all! We have been experiencing an issue on site where threads have been missing the latest postings. The platform host Vanilla are working on this issue. A workaround that has been used by some is to navigate back a page or two to re-sync the thread and this will then show latest posts. Thanks, Mike.

Javascript online/offline problems

  • 12-02-2009 4:57pm
    #1
    Registered Users Posts: 37


    Does anyone here have an explanation for my problem :

    I made a webpage that does a few calculations with the user input when a button is pressed. My javascript does this perfectly when i am viewing the pages locally. It works perfectly on all major browser aswell.

    However, when i upload these pages. My javascript stops working.

    The error console has problems with me refering to my radio buttons etc. For example, when i want to check if a radio button is selected, i use the following code :
    [COLOR=#000000]if(document.form1.radioGroup1[0].checked == true)
    {
      //... blah blah blah
    }
    
    [/COLOR]
    
    As i said, this works fine locally, but when uploaded, i get an error saying :

    document.form1.radioGroup1 is undefined

    ...what do i do?


    Any help would be appreciated

    Thanks



Comments

  • Closed Accounts Posts: 35 dkell


    Can you post the html form code?


  • Registered Users Posts: 37 GhostfaceKillah


    dkell wrote: »
    Can you post the html form code?
    <form action = "calculate();" name = "buttonForm">
                    <input type = "button" name = "calc" value = "Calculate" onmouseup="calculate();">
                </form>
    
    calculate is a huge JS function that does a load of calculations. As i said - it works offline, just not online...strangely

    The reason why i use "onmouseup" is because internet explorer doesn't seem to know what to do with an "onclick" method.


  • Registered Users, Registered Users 2 Posts: 3,594 ✭✭✭forbairt


    you're including the js in an external file ? you're sure its being loaded ?


  • Registered Users Posts: 37 GhostfaceKillah


    forbairt wrote: »
    you're including the js in an external file ? you're sure its being loaded ?

    no the JS is in the html file. Its all one file . Would i be better off making it external?


  • Registered Users, Registered Users 2 Posts: 3,594 ✭✭✭forbairt


    shouldn't make any difference was just wondering if something wasn't getting loaded ... can you give access to the page ?


  • Advertisement
  • Registered Users Posts: 37 GhostfaceKillah


    forbairt wrote: »
    shouldn't make any difference was just wondering if something wasn't getting loaded ... can you give access to the page ?

    I think i've discovered the problem - The hosting site i used was called freeweb7.com. They seem to take out your <Head> tags and replace them with <center> tags?? i think this is what was causing the problem, i hosted the file on graffiti.net and it worked fine. Such a noobish problem...Thanks for the help


  • Registered Users Posts: 37 GhostfaceKillah


    FFS it only works in firefox, not safari or ie (it does work in all of them offline though)

    why can't i say this
    if(document.productSelect.group1[0].checked == true) 
    {
    
    //....
    
    }
    
    the if statement gives me errors on safari and ie

    the html that calls it is :
    <form action="calculate();" name="buttonForm">
    <input name="calc" value="Calculate" onmouseup="calculate();" type="button">
    </form>
    
    
    Webpage url is : http://home.graffiti.net/philkav/DadsWebpage/


  • Registered Users Posts: 85 ✭✭slavigo


    Just a quick observation.
    Your 'group1' fields aren't inside a 'form' element.
    In fact your 'form' element closes straight away and has no content or items inside it.

    I.e. It looks like this:
    <form action="formCheck.html" method="post" name="productSelect"></form>


    I may be missing something here but it's just the first thing that struck me after the quick browse.


  • Registered Users Posts: 37 GhostfaceKillah


    slavigo wrote: »
    Just a quick observation.
    Your 'group1' fields aren't inside a 'form' element.
    In fact your 'form' element closes straight away and has no content or items inside it.

    I.e. It looks like this:
    <form action="formCheck.html" method="post" name="productSelect"></form>


    I may be missing something here but it's just the first thing that struck me after the quick browse.

    Well spotted, See the funny thing is - thats NOT my code. My code is this:
        <form action = "formCheck.html" method = "post" name = "productSelect">
        <tr><td>
            <table border = "0">
    
    
            <!--ROW 1-->
            <tr>
                <td>
                    
                        <font color = "red">1. Select Product </font>
                            <form name = "productSelect">
                                <b><br/>
                                &nbsp;&nbsp;&nbsp;<input type = "radio" name = "group1" id="MPP"> My Broker Mortgage Payment Protection</input><br/>
                                &nbsp;&nbsp;&nbsp;<input type = "radio" name = "group1" id="IP"> My Broker Income Protection</input> 
                                <br/><br/></b>
                            </form>    
    
                </td>
                <td>
                </td>
    

    But when i upload it - it changes and automatically closes the form??

    I hate hosts who change the code you uploaded, its obviously something to do with my table tag i reckon. Thanks, good find, i'll mess around with that bit of code and post my results


  • Closed Accounts Posts: 18,163 ✭✭✭✭Liam Byrne


    There are 2 problems with that

    Firstly, the first form element is immediately prior to a <tr>, which implies it's inside the <table>

    Secondly, you appear to have nested forms, both called "productSelect" ?

    Put the first <form> BEFORE the <table> tag and close the form AFTER the </table>, and remove any "interior "forms".


  • Advertisement
  • Registered Users Posts: 37 GhostfaceKillah


    Perfect, thanks guys. I was programming that page for hours so i guess i made a few dumb mistakes. At least it works now so im in the money!:D


Advertisement