Web Analytics Made Easy -
StatCounter Form help - CodingForum

Announcement

Collapse
No announcement yet.

Form help

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Form help

    Hi guys

    I have a select "combobox" that when you click on an option from the list it submits the value, which is what i want it to do. But I would also like to have the select "combobox" become disabled or greyed out after an option is selected. I can get these to work seperatly but not together. Is it possible to have 2 onchange events in one form?


    here is what i am working with:
    Code:
    <script type="text/javascript">
    function makeDisable(){
        var x=document.getElementById("filter11")
        x.disabled=true
    }
    </script>
    
    <td><Select name='filter11' id="filter11" onChange="filters.submit();" onchange="makeDisable()">
    <option value=''>Months (Any)</option>
    blah blah
    </select>

  • #2
    Despite the similar sounding names, Java is not the same as Javascript.
    Moving from Java forum to Javascript forum.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

    Comment


    • #3
      Apologies...

      Comment


      • #4
        Just call both functions from the *SINGLE* onchange.

        Code:
        <Select name='filter11' id="filter11" onChange="filters.submit();makeDisable()">
        Be yourself. No one else is as qualified.

        Comment


        • #5
          Hi Old pendant.

          Yeah I did try that, it submits the form ok, but it only disables the form for 1 second... I have the form submiting to the same page.(index.php) Should that matter?

          Comment


          • #6
            Oh...once you submit the <form>, the server *RELOADS* the ENTIRE PAGE. So any changes you make via JavaScript will be completely lost in the re-loaded page.

            You will need to take care of this in you server-side code. That is, if this is a PHP page, use PHP code to detect that the <select> has been used and disable it via PHP. (Or ASP or JSP or whatever.)
            Be yourself. No one else is as qualified.

            Comment


            • #7
              ah, I see. That makes sense!

              Will have a go with the php script!

              Thanks

              Comment


              • #8
                Or you could use a Javascript cookie.


                Originally posted by amg182 View Post
                But I would also like to have the select "combobox" become disabled or greyed out after an option is selected.
                Why? That means that the user cannot change his mind. Surely a user-hostile approach!
                Last edited by Philip M; Aug 26, 2011, 03:06 AM.

                All the code given in this post has been tested and is intended to address the question asked.
                Unless stated otherwise it is not just a demonstration.

                Comment

                Working...
                X
                😀
                🥰
                🤢
                😎
                😡
                👍
                👎