Disable submit button untill select box choices

Discussion in 'JavaScript' started by rainat, Jun 5, 2013.

  1. #1
    i've source code how to create SUBMIT BUTTON "ENABLE" when all of selection are chosen.
    But the problem is..it doesn't run when i use Jquery plugin 1.9.1 version,. but it work well when i use Jquery plugin 1.5.2 version,

    Can someone give me a hand how to mae it work using Jquery 1.9.1 version plugin?

    Here is the sample code link
    http://jsfiddle.net/Yr59d/

    Regards
    aat
     
    rainat, Jun 5, 2013 IP
  2. GMF

    GMF Well-Known Member

    Messages:
    855
    Likes Received:
    113
    Best Answers:
    19
    Trophy Points:
    145
    #2
    Erm, why are you using Jquery for this? I'm not good with javascript, but I am pretty sure that you don't need a whole JS framework for something simple like this.


    Wrote something myself, that works without Jquery

    
    <script type="text/javascript">
    function togglesubmit()
    {
        if(document.getElementById('ad_type').value != "" && document.getElementById('ad_duration').value != "")
        {
            document.getElementById('submitorder').disabled = false;
        }
        else
        {
            document.getElementById('submitorder').disabled = true;
        }
    }
    </script>
     
    <form id="ad_form" method="post" action="">
        <p>
            <select id="ad_type" name="ad_type" onchange= "togglesubmit()">
                <option value="" selected="selected">Select premium ad type</option>
                <option value="<?php echo TYPE_USER;?>">Featured Agent</option>
                <option value="<?php echo TYPE_LISTING;?>">Featured Listing</option>
            </select>
            <label for="ad_type" class="labelStrong">Advertising Type</label>
        </p>
        <p>
            <select id="ad_duration" name="ad_duration" togglesubmit= "show()">
                <option value="" selected="selected">Select premium ad duration</option>
                <option value="weekly">Weekly</option>
                <option value="fortnightly">Fortnightly</option>
                <option value="monthly">Monthy</option>
            </select>
            <label for="ad_duration" class="labelStrong">Advertising Duration</label>
        </p>
    
        <p>
            <div id="calender">
            </div>
        </p>
        <p>
            <input type="submit" name="submit" value="Submit" id="submitorder" disabled/>
        </p>
    </form>
    
    HTML:
     
    GMF, Jun 5, 2013 IP