Groups | Blog | Home
all groups > inetserver asp db > october 2004 >

inetserver asp db : Form: extract VALUE and DISPLAY value?


jason NO[at]SPAM catamaranco.com
10/15/2004 3:29:55 PM
What is the best way to extract incoming ID form variables and their
corresponding text values.

Is there an easy way to extract both the initialized value on the form and
its DISPLAY value.

For instance my form element may look this:

<input type=text name="StateID" value=<%=StateID%>>Florida

But, when I process the form I require both the StateID and the Display
value:

StateID=1
State=Florida

Is there a way to do this without looping through the form...I already have
an existing asp processing page for about 30 form fields and hope I don't
have
to revise the page logic too much?

Thanks
Jason

Ray Costanzo [MVP]
10/15/2004 3:50:01 PM
The text, "Florida" is not part of a form element. It is just text within
the page, and it will not be sent to the server when the form is submitted.
You could put that value in a hidden input, if you like. In order for any
data to be submitted to the server on form submission, the data must exist
in an input element, i.e.
<input type="text|password|checkbox|radio|file|image|hidden"> or
<select...> or <textarea...>

So, you could do:
<input type="text" name="StateID" value="<%=StateID%>">Florida
<input type="hidden" name="StateName" value="Florida">

Ray at work

[quoted text, click to view]

jason NO[at]SPAM catamaranco.com
10/15/2004 5:37:22 PM
Ok, but supposing these values were coming out of a database would it be
considered wasteful to implement that 'extra' hidden field for the display
value.

I have seen other concantenate values using eg: '_'
345_Florida
...and they then use string manipulation to seperate them
on the processing page but I find this messy....

Your thoughts?

Thanks
Jason
"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
message news:%23Wr2KAvsEHA.160@TK2MSFTNGP11.phx.gbl...
[quoted text, click to view]

Ray Costanzo [MVP]
10/17/2004 2:18:45 PM
In that case, I'd probably either do a value="345,Florida" or just do
value="345" since the database already knows that 345 corresponds to
Florida. It would depend more on what I needed to do with that "Florida"
data and what it is that makes it necessary to have it submitted.

Ray at home

[quoted text, click to view]

jason NO[at]SPAM catamaranco.com
10/26/2004 6:09:28 PM
Thanks...makes sense.

- Jason
"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
message news:ecdHhWHtEHA.3564@tk2msftngp13.phx.gbl...
[quoted text, click to view]

AddThis Social Bookmark Button