xhtml form with selection list
I need to create a form which uses an appropriate input device (eg. text box) which will allow the user to select the basis for a search. the user should be able to choose between the following options:
*customer last name
*customer number
*order number
so when the user selects one option or a radio button the text box should become active, otherwise it should be inactive.i've done upto the radio button. now need some more help on how to get the text boxes active.
# 1 Re: xhtml form with selection list
Here's how you would disable an input field:
var searchInput = document.getElementById("search");
searchInput.disabled = true;
# 2 Re: xhtml form with selection list
Use the disabled attribute.
<script type="text/javascript">
function checkselected(obj){
if(obj.value == 'text1'){
document.getElementById('text1').disabled = false;
document.getElementById('text2').disabled = true;
}
else{
document.getElementById('text1').disabled = true;
document.getElementById('text2').disabled = false;
}
}
</script>
<input type="text" name="text1" id="text1">
<input type="text" name="text2" id="text2" disabled>
Text 1: <input type="radio" name="selecttext" value="text1" onchange="checkselected(this)">
Text 2: <input type="radio" name="selecttext" value="text2" onchange="checkselected(this)">