I want to disable the text box, based on the value selected from the list box

hi

all

I want to disable the text field base on the value selected from the list box.

Please help me out

Thanks & Regards
MD.Samiuddin

If the value of the selected item in the list box == a certain value, set the disabled property of the textbox to true.

thanks for ur reply

please give the code for this

thanks & regards

Hi

all

I want to disable the text box based on the value selected from the list box

please help me out

Thanks & Regards.

MD.Samiuddin

Can you at least provide the code for the select list and the textbox? and then we can help you with the javascript.

Why are you duplicating your question in another thread?
[URL=“http://www.sitepoint.com/forums/showthread.php?p=4773494#post4773494”]
This thread is the same as this one

hi
this is my code

<select name=“vcat” id=“vcat” >Vehicle-Type
<option name=“vcat” value=“own”>Own
<option name=“vcat” value=“attached”>Attached
</option>
</select>
<input type=“text” name=“vcomm”>
<input type=“text” name=“vstatus”>

when i selected the ‘own’ from the list box then i want to disable the two text boxes

thanks & regards

MD.Samiuddin

That html has errors in it.

Why have you given names to the options? How will you be using those names?

Also, not all your option labels are enclosed properly within option tags.

You need to fix those errors first.

This will do it for you.

You need to have the first select box ( “select …”) so that the onchange handler fires when you move from it to the other two boxes.

[HIGHLIGHT=“”]
<!doctype HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>
<html>

<head>

<meta http-equiv=“Content-Type” content=“text/html; charset=windows-1252”>
<title>Disable Text Boxes</title>
<script type=“text/javascript”>
<!–
function disableTextBox(obj)
{ var selected=document.myForm.mySelect.options[obj.selectedIndex].value;
// invalid selection
if(selected==“999”){ return; }
// ------------
// valid selection
if(selected==“own”)
{ document.myForm.vcomm.disabled=true;
document.myForm.vstatus.disabled=true;
}
}
//–>
</script>
</head>

<body>

<form name=“myForm”>
<p><select name=“mySelect” onchange=“disableTextBox(this)”>
<option value=“999”>Select …</option>
<option value=“own”>Own</option>
<option value=“attached”>Attached</option>
</select> <input type=“text” name=“vcomm” value=“12345”>
<input type=“text” name=“vstatus” value=“98765”> </p>
</form>

</body>

</html>

Answered in the php forum