Topic: dynamically write hidden input from select box selected index (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=29208" title="Pages that link to Topic: dynamically write hidden input from select box selected index (Page 1 of 1)" rel="nofollow" >Topic: dynamically write hidden input from select box selected index <span class="small">(Page 1 of 1)</span>\

 
Boudga
Maniac (V) Mad Scientist

From: Jacks raging bile duct....
Insane since: Mar 2000

posted posted 05-12-2007 14:41

Hi all,

I have a select box with data that looks like this:

code:
<select name="retailers_stateabbr" size="1" class="formStyle" >
                      <option value="">Select a state</option>
                      <option id="Alabama" value="AL">AL</option>
                      <option id="Alaska" value="AK">AK</option>
                      <option id="Arizona" value="AR">AR</option>
                      <option id="Arizona" value="AZ">AZ</option>
                      <option id="California" value="CA">CA</option>
</select>



I currently am writing the selected value to a table in my db however I would like to write the selected value's ID to another column on the same table in my db.

I'm thinking that it would require creation of a function that uses getElementByID to document.write a hidden input. Does anyone have a function that works this way that I could reference to write my own function correctly?

Couldn't I use PHP to echo the ID using the getElementById() function to a hidden input? If so, any recommendations on how to do it?

Thanks,

Boudga

(Edited by Boudga on 05-12-2007 15:07)

poi
Paranoid (IV) Inmate

From: Norway
Insane since: Jun 2002

posted posted 05-12-2007 15:38

What ?!

Can't you simply do two INSERT in your DB ? I don't get it.

And come on, if your target browsers support getElementById() surely they also support createElement() and the other DOM methods. To the hell with document.write().

You realize that once the form is submitted, you'll have an Array* called $retailers_stateabbr in your POST or GET ( depending on the method you set on the FORM tag ). You can use/manipulate/output that array at will.

*: if more than one OPTION was selected.

Skaarjj
Maniac (V) Mad Scientist

From: :morF
Insane since: May 2000

posted posted 05-16-2007 05:02

poi's quite right. Once the form's submitted, all the information from your form will be i nthe PHP page you submit the form to. You can insert each piece of data wherever you want as many times as you want. You could spit out a never-ending page with all your options printed on leet-speak if you wanted


Justice 4 Pat Richard



Post Reply
 
Your User Name:
Your Password:
Login Options:
 
Your Text:
Loading...
Options:


« BackwardsOnwards »

Show Forum Drop Down Menu