I have a form in which there are a few radio buttons and a dropdown box.
What I want?
The HTML and JS I've tried is mentioned below. Any help would be appreciated.
HTML
<label class="radio-inline"><input type="radio" name="type" id="type" value="receipt" onClick="party_check()" />Receipt</label>
<label class="radio-inline"><input type="radio" name="type" id="type" value="payment" onClick="party_check()" />Payment</label>
<label class="radio-inline"><input type="radio" name="type" id="type" value="other income" onClick="party_check()" />Other Income</label>
<label class="radio-inline"><input type="radio" name="type" id="type" value="other expense" onClick="party_check()" />Other Expense</label>
<select name="party" id="party" class="form-control">
<option value="">Please select an option</option>
<option value="1">Option 1</option>
<option value="2">Option 2</option>
</select>
JS
function party_check(){
if((document.type[0].checked) || (document.type[1].checked)){
document.getElementById("party").disabled=false;
}
else
{
document.getElementById("party").disabled=true;
}
}
Check this
Html
<label class="radio-inline"><input type="radio" name="type" value="receipt" onclick="party_check(this)" />Receipt</label>
<label class="radio-inline"><input type="radio" name="type" value="payment" onclick="party_check(this)" />Payment</label>
<label class="radio-inline"><input type="radio" name="type" value="other income" onclick="party_check(this)" />Other Income</label>
<label class="radio-inline"><input type="radio" name="type" value="other expense" onclick="party_check(this)" />Other Expense
</label>
<select name="party" id="party" class="form-control">
<option value="">Please select an option</option>
<option value="1">Option 1</option>
<option value="2">Option 2</option>
</select>
Javascript
function party_check(rad){
if(rad.value == "receipt" || rad.value == "payment"){
document.getElementById("party").disabled=false;
}else{
document.getElementById("party").disabled=true;
}
}
"id" attribute's value must be unique across the tags in the html page
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With