Writing a listbox value to an html link concatination

C

Crystal

Ok, I know this sounds weird, but it's really bugging me. I have a
few list boxes on my form (basic pick a month, year, state stuff) and
you can only choose one value. I need to be able to run a script to
pick out those boxes and request the value and then response.write the
value to a URL that I am creating. The script actually sends an email
to me that contains a link to the form that the user filled in and
populates the form with their information. Here is what I have so
far, only the first and last cases work, I still can't figure out how
to get it to work for "sel" (listboxes) and I also need to make it
work for a text area:

<%
sub RequestInfo(objName, btnVal)
Select Case left(objName,3)
Case "rad", "chk"
if Request(objName)=btnVal then
Response.Write("checked")
end if
Case "sel"
if Request(objName)=btnVal then
Response.Write("selected")
end if
Case "txt"
Response.Write "Value='" & Request(objName) & "'"
End Select
end sub
%>

Any help would be GREATLY appreciated! I just need it to write the
selected value, don't worry about where it's coming from or where it's
going, that all works fine :)
 
S

SPA

Hi

First of all, need to know how u populate your listbox control. It should be
like:

<select name="lst_Date">
<option value="1">1</option>
<option value="2">2</option>
</select>

If the value attribute has a value, then you could use
Request.Form("lst_Date") in the form you are posting your page to.

If you are not posting, then you should use the options[selectedIndex].value
property of the listbox in Javascript. You can retrieve this and use it in
your hyperlink.

Syntax:
document.<form name>.<listbox name>.options[selectedIndex].value

Hope this is what you want.
 
C

Crystal

Yeah, I have a plain static list box for selecting a state, simple
enough and it's set up normally and hard coded. However, the way my
code works is that I need to be able to capture the value that was
selected and then pass that value to another function. This is how a
text box works: Within the page with the form, each of the input
forms looks something like this, with the tag on the end.

<input name="txtName" type="text" <%Call RequestInfo("txtName", "")%>>

In a separate "scripts" page, the method then calls the "RequestInfo()
from the form tags. On submit, the scripts page is run and runs
through all of the tags in the form, checking them against each case
and the "btnVal" is then written to the URL, not posted:

<%
sub RequestInfo(objName, btnVal)
Select Case left(objName,3)
Case "rad", "chk"
if Request(objName)=btnVal then
Response.Write("checked")
end if
Case "sel"
if Request(objName)=btnVal then
Response.Write("selected")
end if
Case "txt"
Response.Write "Value='" & Request(objName) & "'"
End Select
end sub
%>


My problem is that I am not quite sure how to get the <%Call
RequestInfo....> to pull out the actual VALUE of what was selected in
the listbox and I really don't want to have to hardcode each of the
listboxes in that scripts page. Any ideas on how to dynamically
capture that value?

I know this is rather confusing, I have confused myself, but any help
would be greatly appreciated.
 
C

Crystal

I got it! I had a friend help me with it and it takes a lot of code
to do it. But it's done, if anyone wants the code, email me at
(e-mail address removed), I'll be happy to send it to you that way, it's just
way to much code to put in a forum.

Crystal
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,044
Latest member
RonaldNen

Latest Threads

Top