Reply
Dynamic field name
Old 06-07-2005, 07:29 PM Dynamic field name
Novice Talker

Posts: 10
Hi there people

Is it possible to change the name of a text field with radio buttons.
I picture three radio buttons, and a field which name will change according to which radio button is checked.

I think maybe this should be done roughly like this (pseudocode):

<input type="text" name="variable">
onSubmit =
if radio1 checked: variable = name1
if radio2 checked: variable = name 2
...

or maybe it is better to do it another way?
I'd appriciate some help in this matter.
oreoT is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 06-08-2005, 03:43 AM
chrishirst's Avatar
Super Moderator

Latest Blog Post:
Am I impressed or what?
Posts: 14,899
Location: Blackpool. UK
If you change the name of the field client side it makes it a little more complicated when recovering the submitted data.

Explain why you want to do something like this and there probably will be a solution.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 06-08-2005, 04:09 AM I'll explain
Novice Talker

Posts: 10
I'm making an ordering form for a take away buffet resturant.
The customers can choose menu size (small, medium, large) and for how many people the order is.
I already have a shopping cart script which I have modified and am happy with it.
So there are actually 3 items to order (small, medium and large), but there will only be 1 field for entering quantety, and the item will change according to which radio button is checked

So if radiobutton1 is checked I want the the form to submit a textfield with the value X and name A. If radiobutton2 is checked I want the form to submit a text field with the value X and name B.

The php script i use, uses the form name to recognize which item has been ordered.

Istead of this:
Small [ 0 ] (name=A)
Medium [ 5 ] (name=B)
Large [ 0 ] (name=C)

I need this:
Qty [ 5 ]
Size: oSmall ĪMedium oLarge

I cant seem to find a good solution to this.
oreoT is offline
Reply With Quote
View Public Profile
 
Old 06-08-2005, 06:35 AM
chrishirst's Avatar
Super Moderator

Latest Blog Post:
Am I impressed or what?
Posts: 14,899
Location: Blackpool. UK
maybe use a hidden field called size and set the value accordingly
You need to cover radio buttons onClick event and the onBlur event for the text field
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 06-08-2005, 08:18 AM
Novice Talker

Posts: 10
Thanks for all the help!
I figured it out using php.
oreoT is offline
Reply With Quote
View Public Profile
 
Old 06-08-2005, 10:22 AM
chrishirst's Avatar
Super Moderator

Latest Blog Post:
Am I impressed or what?
Posts: 14,899
Location: Blackpool. UK
definitely the best option IMO
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to Dynamic field name
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.13101 seconds with 12 queries