Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: Submit

  1. #1
    New Coder
    Join Date
    Aug 2010
    Posts
    16
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Submit

    Hi,


    I want submit a form when highlight options select value = true.

    I did the following code, but it not works. Could someone help me to fix it?


    <script type="text/javascript" language="JavaScript">
    if onfocus="url.select()"
    Return true; {
    document.form1.submit();
    }
    </script>
    stickers

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,238
    Thanks
    203
    Thanked 2,554 Times in 2,532 Posts
    Quote Originally Posted by stickers View Post
    I want submit a form when highlight options select value = true.
    Waht does that mean? Do you want to submit a form when a particular select box option is selected? Please give a clearer example.

    Javascript is case sensitive - so Return true will not do anything. If it did then that would end the function and the next line document.form1.submit(); is never reached. I have no idea what the braces {} are supposed to do.


    All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

  • #3
    New Coder
    Join Date
    Aug 2010
    Posts
    16
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Exactly. I want to submit a form when a particular select box option is selected (onfocus)?

    Best regards

    stickers

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,238
    Thanks
    203
    Thanked 2,554 Times in 2,532 Posts
    Like this:-


    Code:
    <select id = "mySel" onchange="go()">
    <option value = 0>Choose .....</option>
    <option value = 1>Option 1</option>
    <option value = 2>Option 2</option>
    <option value = 3>Submit The Form</option>
    </select>
    
    <script type = "text/javascript">
    
    function go() {
    var val = document.getElementById("mySel").value;
    if (val == 3) {
    document.form1.submit();
    }
    
    }
    
    </script>

  • Users who have thanked Philip M for this post:

    stickers (09-05-2010)


  •  

    Posting Permissions

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