[thelist] ASP & HTML: Pass double data from a Select

Casey Crookston casey at thecrookstons.com
Tue Jul 15 13:06:00 CDT 2003


Hello List,



In an ASP app, I've got an HTML select object within a form:



<select name='fruit'>

     <option value='1'>apples</option>

     <option value='2'>peaches</option>

</select>



I need to pass BOTH the value (1 or 2) and the user-visible options (apples
or peaches).  Before committing to the database, which will contain the
value (1 or 2) the user will have a preview page, which will need to show
the fruit they selected.  1 and 2 mean nothing to the user.



What's the best way to pass along both values?  A hidden tag?  Then what do
you set the value to?  Can you populate the value of a hidden tag with
JavaScript based on what is selected in the <select>?  I could, of course,
only pass the fruit_id (1 or 2) and then do a round trip to the db to grab
the title again, but that seems awful laborius.  I could also make the
values be "1_apple" and "2_peach" and then seperate them on the next page,
but again, this seems like a lot of effort for a small task.



Is there a better way?



Hope this makes sense,



Casey



P.S.  Of course I'm not actually dealing with fruit, just in case you
wondered, but it seemed much more fun them commercial construction
categories.












More information about the thelist mailing list