Results 1 to 4 of 4

Thread: Call a javascript function

  1. #1
    Join Date
    May 2006
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Call a javascript function

    <script language="javascript">

    function disable(){
    document.getElementById("submit").disabled=true;
    }

    </script>

    <html>
    <body>
    <%
    String flag="view";
    if(flag.equals("view"){%>
    <script type="text/javascript">
    disable();
    </script><%
    }
    %>


    <input type="submit" onClick="onSubmit();" id="submit" value="Submit" style="width:85px"/>

    </body>
    </html>

    wanna ask, for example the calling the function code is correct or not?
    before call the function, first check the flag is it 'view' or not, if 'view' then only perform the function.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    This is not purely a javascript question however, it has been my experience that it is usually a bad idea to use a reserved word like 'submit' as a name or an id. This tends to confuse some browsers and when it does, will complicate any troubleshooting efforts.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Yes, that is the correct way to do it.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  4. #4
    Join Date
    May 2006
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    i see. thx.

Bookmarks

Posting Permissions

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