Yes/No disable text box

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
liderbug
New php-forum User
New php-forum User
Posts: 20
Joined: Mon Feb 14, 2011 7:14 pm

Sat Jul 16, 2011 6:46 pm

I've got a requirement for a pair of radio buttons - Yes-No. If No then the input type=text disabled. If Yes then enabled. I found the perfect script - minor problem <form> <form> script </form> </form> - You can't do that. No nested FORM. Ideas.

Thanks

User avatar
webinfopedia
New php-forum User
New php-forum User
Posts: 84
Joined: Sat May 21, 2011 10:26 pm
Contact:

Sun Jul 17, 2011 6:56 am

Hi.
Read below article called dynamic form creation:

http://www.webinfopedia.com/dynamic-for ... ation.html

Customize according to your need.. Hope this will help you..
Thank You

liderbug
New php-forum User
New php-forum User
Posts: 20
Joined: Mon Feb 14, 2011 7:14 pm

Sun Jul 17, 2011 9:55 am

Buy dat person a beer. :D

Took a bit - not knowing the code and figuring out what I could cut out and what I couldn't - customer wouldn't be to happy with a google ad popping up :o

So I ended up with:
------------------------------------------------------
Budget: [ No. Open Bidding. ^/v ]
------------------------------------------------------ or
Budget: [ Yes. ^/v ]
Budget amount: $ [ 123.45 ]
------------------------------------------------------

Just exactly what I was looking for.

Many thanks.
Cal

User avatar
gandahar
New php-forum User
New php-forum User
Posts: 112
Joined: Tue Mar 15, 2011 4:05 am

Mon Jul 18, 2011 12:39 am

here a working example :

Code: Select all

<form name="" action="">

<input type="radio" name="radioGroup" value="No" onclick="document.getElementById('theTXTBox').disabled='disabled';">

<input type="radio" name="radioGroup" value="Yes" onclick="document.getElementById('theTXTBox').disabled=false;">

<input type="text" name="theTXTBox" id="theTXTBox" value="">


</form>
bye

liderbug
New php-forum User
New php-forum User
Posts: 20
Joined: Mon Feb 14, 2011 7:14 pm

Mon Jul 18, 2011 6:49 am

Ah, Short and sweet (very sweet) (two beers fer u) :D

Thanks

Post Reply