Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



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

Posts: 10
Trades: 0
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
 
 
Register now for full access!
Old 06-08-2005, 03:43 AM
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
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!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
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
Trades: 0
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
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
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!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 06-08-2005, 08:18 AM
Novice Talker

Posts: 10
Trades: 0
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
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
definitely the best option IMO
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to Dynamic field name
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB 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.22323 seconds with 12 queries