Add toggle to select: bootstrap

I am trying to add select input field to twitter bootstrap. I am going to display different fields when you select each of these options. I tried this using data. But I could only succeed with the buttons, and not in the selection box.

<div class="control-group">
                                            <label class="control-label">Payment Mode</label>
                                            <div class="controls">
                                                <select id="payment" class="input-xlarge">
                                                    <option value="" class="input-xlarge">Select your Payment mode</option>
                                                    <option value="1"> <a href="#cash">Cheque Deposit</a></option>
                                                    <option value="2">Online Transaction</option>
                                                    <option value="3">ATM Transfer</option>
                                                    <option value="4">IMPS Transfer</option>
                                                </select>
                                            </div>
                                        </div>

This button code works fine -

<button data-toggle="collapse" href="#cash">
Submit 
</button>

Greetings in advance Shahzad

+4
source share
1 answer

Finally got the answer! :) Just the script did the trick. Here is how I did it:

<div class="control-group">
<label class="control-label">Payment Mode</label>
<div class="controls">
    <select id="payment" class="input-xlarge">
        <option value="" class="input-xlarge">Select your Payment mode</option>
        <option value="cash">Cash Deposit</option>
        <option value="cheque">Cheque Deposit</option>
        <option value="online">Online Transaction</option>
        <option value="transfer">ATM Transfer</option>
    </select>
</div>

<div class="iscash" >
<div class="control-group">

        <input class="input-xlarge focused" id="focusedInput" type="text">

</div>
<div class="control-group">

        <input class="input-xlarge focused" id="focusedInput" type="text">

</div>

<script>
    $('[class^=is]').hide();

    $("#payment").change(function() {
        var value = $("#payment option:selected").val();
        var theDiv = $(".is" + value);

        theDiv.slideDown();
        theDiv.siblings('[class^=is]').slideUp();
    });
</script>
+3
source

All Articles