0

Hi All,
I am fresh to php.Please help me in following scenario.

I am trying to enable/disable a text by selecting 'Yes' or 'No' option of a combo box which is available on same page.

Note: It should only work with 'Yes'/'No' option selection not with a submit button click.

Kindly hep by sharing idea or any cod e vaialble.

Thanks in advance.

2
Contributors
3
Replies
6
Views
8 Years
Discussion Span
Last Post by BzzBee
0

if you want to submit a page but you dont want to do that by submit button but on selection the combo box option then use

<select name='cmb' onchange='submit()' >
<option 1>
<option 2>
</select>

in this way when ever you will change your selection e.g from YESto NO or NO to YES it will submit your page and give you the value of the combo field. you can post that value and can use according to ur needs.

0

Hi ,
Thanks for your reply.
I donot want to submit the page in any condition because if I submit the page by selecting the item from combo it will wipe out/reset other field values on same page.

Please suggest any other alternative.

0

if you just want to enable/disable text field on selection then use following code

<html>
<body>
<form name="myform" action="" method="post">
<select name="mycmb" id="mycmb" onchange="enabledisabletext()" >
<option value="yes">YES</option>
<option value="no">NO</option>
</select>
<br /><br />
<input type="text" name="mytext1"  /><br />
<input type="text" name="mytext2" />
</form>
</body>
</html>

<script language="javascript">
function enabledisabletext()
{
	if(document.myform.mycmb.value=='yes')
	{
	document.myform.mytext1.disabled=true;
	document.myform.mytext2.disabled=false;
	}
	if(document.myform.mycmb.value=='no')
	{
	document.myform.mytext1.disabled=false;
	document.myform.mytext2.disabled=true;
	}
}
</script>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.