Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

get option value though ASP without form Submit

Status
Not open for further replies.

deharris2003

Programmer
Jul 1, 2003
41
US
I want ot know how to get the value of an option button without submitting the form.

Thanks
 
you can send it in a URL and extract the querystring with a bit of client scripting after a event

____________________________________________________
The most important part of your thread is the subject line.
Make it clear and about the topic so we can find it later for reference. Please!! faq333-3811

onpnt2.gif
 
heres my code -- This part works fine.

<%If strRenewal > Date() AND strRenewal < Date() + 180 Then %>
<td width=&quot;24&quot;><img border=&quot;0&quot; src=&quot;../images/attention.gif&quot; width=&quot;24&quot; height=&quot;22&quot;></td>
<td><a href=&quot;Main_Menu.asp?ID=<%=rst(&quot;AUTOID&quot;)%>&quot;><%=rst(&quot;Company_Name&quot;)%></td></a></td>
<%Else%>
<td width=&quot;24&quot;></td>
<td><a href=&quot;Main_Menu.asp?ID=<%=rst(&quot;AUTOID&quot;)%>&quot;><%=rst(&quot;Company_Name&quot;)%></td></a></td>
<%End If%>

Problem is I have a option value that I would like to include in the query string. I do not know how to do that

<input type=&quot;radio&quot; value=&quot;Modify&quot; name=&quot;Req_Type&quot; checked>Modify Contract
<input type=&quot;radio&quot; value=&quot;View&quot; name=&quot;Req_Type&quot;>View
Contract </p>
 
you'll need to run a client side script prior to redirection. in some way add a event to the click of the link
eg:
<a href=&quot;#&quot; onClick=&quot;goWithOption()&quot;><%=rst(&quot;Company_Name&quot;)%>

now you could use vbscript but I'm guesing that you need this to work on more then IE so use javascript.
Teh function will need to loop through the radio's sense you named them the same thing
so the frst stage is to figure out which returns true for checked.
var valChecked = &quot;&quot;
for (i=0;i<document.MyForm.Req_Type.length;i++) {
if (document.MyForm.Req_Type.checked) {
valChecked = document.MyForm.Req_Type.value
}
}
There's your loop through the two values to get the proper value returned and should be sent through as the querystring.
now all you need to do is build the URL
notice the replacement prior of the # in the URL value of the href. Here you can perfomr that substitution with a window.location = path
so to build the path jsut concate the values together. Seeing as the ASP portion is going to run prior to the interprutation of the HTML you can still add the value in the client script in the head as you did before
var MyURL = &quot;Main_Menu.asp?ID=<%=rst(&quot;AUTOID&quot;)%>&&quot;
MyURL += &quot;Req_Type=&quot; + valChecked
window.location = MyURL

provided this is on the fly logic and syntax it seemingly may be the best way to get the functionality you want I think

____________________________________________________
The most important part of your thread is the subject line.
Make it clear and about the topic so we can find it later for reference. Please!! faq333-3811

onpnt2.gif
 
I made the changes. I still cannot get it to work. Did however change one thing, I am passing in the AUTOID number to the function as a variable instead of calling it in the function. Problem I see with calling it is that how will the computer know what AUTOID number to pull in relation to the company that was selected. anyway

<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
function goWithOption(intIDNUM)
{
var valChecked = &quot;&quot;
for (i=0;i<document.MyForm.Req_Type.length;i++)
{
if (document.MyForm.Req_Type.checked)
{
valChecked = document.MyForm.Req_Type.value
}
}
var MyURL = &quot;Main_Menu.asp?ID=&quot; + intIDNUM
MyURL += &quot;&Req_Type=&quot; + valChecked
window.location = MyURL
return true
}
</script>


I am totally no good with Javascript but as you stated i need to include the correct syntac.

Also I am not sure what you mean by the replacement prior to #

<a href=&quot;#&quot; onClick=&quot;goWithOption(rst(&quot;AUTOID&quot;))&quot;><%=rst(&quot;Company_Name&quot;)%>


Thanks again for all your help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top