(Link to AcmlmWiki) Offline: thank ||bass
Register | Login
Views: 13,040,846
Main | Memberlist | Active users | Calendar | Chat | Online users
Ranks | FAQ | ACS | Stats | Color Chart | Search | Photo album
05-20-24 01:36 PM
0 users currently in Programming.
Acmlm's Board - I3 Archive - Programming - Using Radio And Text Input For The Same Form Element New poll | |
Add to favorites | Next newer thread | Next older thread
User Post
Elric

Octoballoon


 





Since: 11-18-05
From: Melniboné

Last post: 6698 days
Last view: 6330 days
Posted on 12-02-05 05:31 AM Link | Quote
Yeah, the title may be a little confusing, since I'm not exactly sure how to sum it up...

Anyway, what I want to do is have a for with a set of choices. You pick your choice by radio button, but I want the last choice to allow you to enter custom data into a text-type input (input type=text not <textarea>).

My problem is this: I can make it save the data from one OR the other, but not both. For example, if I have this:

Thing A Thing B Custom:
(code: <input type=radio name=test value=A>Thing A <input type=radio name=test value=B>Thing B <input type=radio name=test value=C>Custom:<input type=text name=test>)

I can make it so that anything entered in Custom is saved, but then if Thing A or Thing B is selected, it ignores it, and just saves whatever was last in Custom. Or, I can make it so that it saves the data from Thing A or Thing B, but if Custom is selected, it ignores it, and just saves the data from whichever Thing (A or B) was chosen last.

How do I make it so that it saves the data from whatever one is chosen?
neotransotaku

Sledge Brother
Liberated from school...until MLK day








Since: 11-17-05
From: In Hearst Field Annex...

Last post: 6303 days
Last view: 6300 days
Posted on 12-02-05 02:40 PM Link | Quote
Could you try to use javascript form processing before you submit your form to wherever your form is going to go? This way, you can set a specific variable that will take data from one of those three?
Elric

Octoballoon


 





Since: 11-18-05
From: Melniboné

Last post: 6698 days
Last view: 6330 days
Posted on 12-02-05 03:42 PM Link | Quote
1) It's for my board, so probably not...
2) I don't know JS...
Cellar Dweller +

Red Koopa









Since: 11-18-05
From: Arkansas

Last post: 6310 days
Last view: 6301 days
Posted on 12-02-05 10:35 PM Link | Quote
It's simple. Give the text and radio inputs seperate names, and have your PHP(or whatever) script check to see if the custom radio button is selected. If it is, save the value in the text field, else save the value in the radio field.

For example, if the radio field is named test_radio and the text field is named test_text you can have
if ($test_radio == "C") {

$test = $test_text;
} else {
$test = $test_radio;
}

in your PHP code or, more compactly,
$test = ($test_radio == "C")?$test_text:$test_radio;

.
Add to favorites | Next newer thread | Next older thread
Acmlm's Board - I3 Archive - Programming - Using Radio And Text Input For The Same Form Element |


ABII

Acmlmboard 1.92.999, 9/17/2006
©2000-2006 Acmlm, Emuz, Blades, Xkeeper

Page rendered in 0.005 seconds; used 362.17 kB (max 428.80 kB)