Jump to content

Recommended Posts

i have a screen where apart from other fields, i have these two fields:

<tr>
<td><div align="right"><font class="inputLbl">Wireless
    Access:  </font></div></td>
<td><select name="wirelessaccess" >
<?
	if (isset ($wireless))
	{
	     print ("<option value='$wireless' selected>$wireless</option>");

	     if ($wireless == "Yes")
	     {
		  print("<option value='No'>No</option> ");
	     }
	     elseif ($wireless == "No")
	     {
	          print("<option value='Yes'>Yes</option>");
	     }
	}
	else
	{
	     print("<option value='No' selected>No</option> ");
	     print("<option value='Yes'>Yes</option>");

	}

	?>
  </select></td>
</tr>
<tr>
<td><div align="right"><font class="inputLbl">PIN:  </font></div></td>
<td><input name="phypin" type="text"  class="txtboxLarge" id="phypin" value="<?PHP print($rowz["phy_pin"]); ?>"></td>
</tr>                   

 

what i need to do is, be able to enter some info in the field if the wirelessaccess field takes the value 'Yes'. the field can be made readonly if wireless access field takes 'No'.

 

How can i do this? i am stuck at this point. is this possible with php - i guess php is a server side script. any help will be gladly appreciated. thanx in advance

Link to comment
https://forums.phpfreaks.com/topic/97842-help-with-field-enabledisable/
Share on other sites

i dont really understand what you are trying to do,

 

you have a select tag, and depending on the results

of what the user selects you want to echo either an

input where the user puts more info or a read only

input tag with pre-written info? is that what you are

trying to do?

no no no. the wirelessaccess field is a drop down with 'Yes' or 'No' as the options. If user selects 'Yes' here, then the next field on screen, PIN is a write only field where user enters a pin ( i am doing PIN validations on this field to make sure the correct one gets thru).

 

If the user chooses 'No' for wirelessaccess field, then the PIN field is made 'readonly' user cannot edit this field. this field may or maynot be blank onload. if wireless acess is 'Yes', the PIN field is mandatory(where user enters info) else the field is readonly(user cannot enter any info).

 

hope im clear now...

oh, now i understand, you can do this with javascript,

try this code before your form

 

<script type="text/javascript">
function checkPin(yesno){
if(yesno == 'yes'){
document.forms[0].phypin.disabled=false;
} else{
document.forms[0].phypin.disabled=true;
}
}
</script>

 

(the code above will only work if this is the only form on that page,

if not add the name attribute to the form and change the 0 in the

brackets where it says forms and add the name of the form)

 

then add this code:

 

<tr>
<td><div align="right"><font class="inputLbl">Wireless
    Access:  </font></div></td>
<td><select name="wirelessaccess" >
<?
	if (isset ($wireless))
	{
	     print ("<option value='$wireless' selected>$wireless</option>");

	     if ($wireless == "Yes")
	     {
		  print("<option onClick=\"checkPin('no')\" value='No'>No</option> ");
	     }
	     elseif ($wireless == "No")
	     {
	          print("<option onClick=\"checkPin('yes')\" value='Yes'>Yes</option>");
	     }
	}
	else
	{
	     print("<option onClick=\"checkPin('no')\" value='No' selected>No</option> ");
	     print("<option onClick=\"checkPin('yes')\" value='Yes'>Yes</option>");

	}

	?>
  </select></td>
</tr>
<tr>
<td><div align="right"><font class="inputLbl">PIN:  </font></div></td>
<td><input name="phypin" type="text"  class="txtboxLarge" id="phypin" value="<?PHP print($rowz["phy_pin"]); ?>"></td>
</tr> 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.