(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
06-03-24 06:16 AM
0 users currently in Programming.
Acmlm's Board - I3 Archive - Programming - Using Radio And Text Input For The Same Form Element
  
User name:
Password:
Reply:
 
Options: - -
Quik-Attach:
Preview for more options

Max size 1.00 MB, types: png, gif, jpg, txt, zip, rar, tar, gz, 7z, ace, mp3, ogg, mid, ips, bz2, lzh, psd

UserPost
Cellar Dweller +
Posts: 6/138
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;

.
Elric
Posts: 77/164
1) It's for my board, so probably not...
2) I don't know JS...
neotransotaku
Posts: 101/1860
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
Posts: 75/164
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?
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.010 seconds; used 349.38 kB (max 381.98 kB)