form select, affected input form

Javascript coding ..

Moderators: egami, macek, gesf

Post Reply
rudy_keren
New php-forum User
New php-forum User
Posts: 16
Joined: Tue Mar 28, 2006 10:13 am
Location: indonesia
Contact:

Sun Apr 09, 2006 8:08 am

hello guys,

i have a problem here. Can any one help me??

Ok, i have a page which contain a form like <select> and <input textfield>. There are 4 option in <select><option> form, i can say those option are ie:a,b,c and d. When i choosed the option c, it will be take efect for input form, and input will be disabled. when i choose others the input form will activated disable into enable. Can u get this point?? So when i choose value c in <select><option> form, i can not write anything in <input > text field. And when others option except d, i can fill the textfield.

Thats all for me. Thx for help.

sanketce
New php-forum User
New php-forum User
Posts: 90
Joined: Fri Dec 02, 2005 3:23 am

Sun Apr 09, 2006 10:42 pm

Please post your code portion here...

Coditor
New php-forum User
New php-forum User
Posts: 243
Joined: Wed Feb 01, 2006 9:18 am
Location: Netherlands
Contact:

Sun Apr 09, 2006 11:53 pm

I think he wants us to make the code :)

Code: Select all

<select name="somedropdown" onchange="document.getElementById('atextfield').readOnly=(this.value=='3');">
<option value="1">No problem</option>
<option value="2">Still ok</option>
<option value="3">Blocked input</option>
<option value="4">Fine again</option>
</select><br />
<input type="text" name="sometext" id="atextfield" />
Ofcourse it can be more complex than this if you want other criteria to enable or disable the textfield.

Coditor

rudy_keren
New php-forum User
New php-forum User
Posts: 16
Joined: Tue Mar 28, 2006 10:13 am
Location: indonesia
Contact:

Tue Apr 11, 2006 1:11 pm

ok, thx for solutions, but i need one option in selected form effect 2 input textfield disabled ??? Can i get the source??

Thx b4..

Coditor
New php-forum User
New php-forum User
Posts: 243
Joined: Wed Feb 01, 2006 9:18 am
Location: Netherlands
Contact:

Wed Apr 12, 2006 12:21 am

I'm not sure what you mean but the example can be extended to do anything you want...

If you can give an example form in HTML and explain in detail what it should do I can help you along..

Coditor

rudy_keren
New php-forum User
New php-forum User
Posts: 16
Joined: Tue Mar 28, 2006 10:13 am
Location: indonesia
Contact:

Sat Apr 15, 2006 6:32 pm

I'm not sure what you mean but the example can be extended to do anything you want...

If you can give an example form in HTML and explain in detail what it should do I can help you along..

Coditor
Thx b4, what i mean is your code can be implemented on 2 textfield, here is the source

Code: Select all


<form id="form1" name="form1" method="post" action="">
  <select name="somedropdown" >
<option value="1">No problem</option>
 <option value="2">Still ok</option>
 <option value="3">Blocked input</option>
 <option value="4">Fine again</option>
 </select></select>
 <input type="text" name="sometext" id="atextfield" />
  <input type="text" name="sometext" id="btextfield" />
</form>

When the user select number 3, which mean "Blocked Input" , i need those 2 textfield are blocked. Thx !

Coditor
New php-forum User
New php-forum User
Posts: 243
Joined: Wed Feb 01, 2006 9:18 am
Location: Netherlands
Contact:

Sun Apr 16, 2006 3:09 am

So you want both textfields to be disabled?

Code: Select all

<select name="somedropdown" onchange="document.getElementById('atextfield').readOnly=(this.value=='3');document.getElementById('btextfield').readOnly=(this.value=='3');">
If it gets more complex, create a separate function that's called:

Code: Select all

<script language="javascript" type="text/javascript">
function selectDrop(obj) {
   document.getElementById('atextfield').readOnly = (obj.value == '3');
   document.getElementById('btextfield').readOnly = (obj.value == '3');
}
</script>
<select name="somedropdown" onchange="selectDrop(this);">
Coditor

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 2 guests