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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dynamic links

Status
Not open for further replies.

trc

MIS
Nov 27, 2000
126
CA
How can I make a link value based on the selection in a menu? What I am trying to do is:
1) determine if a record in a database has multiple records
2) If it does display a menu
3) have a url based on the selection in the menu

1 and 2 are done. How do I do number 3?

Here is my code

<body bgcolor=&quot;#ffffff&quot; text=&quot;#000000&quot; leftmargin=&quot;0&quot; marginwidth=&quot;0&quot; marginheight=&quot;0&quot; topmargin=&quot;0&quot;>


<table width=&quot;500&quot; height=&quot;350&quot; background=&quot;images/showitem.gif&quot;>
<tr>
<td height=&quot;22&quot;> </td>
<td height=&quot;22&quot;>
<%
'on error resume next
dim intProductID
intProductID = clng(0 + Request(&quot;PID&quot;))
if (intProductID > 0) then
dim adoDBConnect
Set adoDBConnect = Server.CreateObject(&quot;ADODB.Connection&quot;)
adoDBConnect.Open &quot;DRIVER=Microsoft Access Driver (*.mdb);FIL=MS Access;DBQ=&quot; & Server.MapPath(&quot;/database/20010208.mdb&quot;), &quot;admin&quot;, &quot;&quot;

dim recProduct
set recProduct = Server.CreateObject(&quot;ADODB.RecordSet&quot;)
recProduct.CacheSize = 10
recProduct.CursorLocation = 3
recProduct.Open &quot;SELECT * FROM queryPRODUCTLIST WHERE (queryPRODUCTLIST.ID=&quot; & intProductID & &quot;);&quot;, adoDBConnect
if ((err.number = 0) and (not (recProduct.BOF and recProduct.EOF))) then
dim intTempUID
dim strTempNAME
intTempUID = recProduct(&quot;ID&quot;)
strTempNAME = replace(recProduct(&quot;NAME&quot;), &quot;'&quot;, &quot;\'&quot;)
%>
<script>
<!--
var PidValue

function updatePID(select) {
PidValue = select.selectedIndex;
return;
}

//Not sure if needed -->

</script>
</td>
<td nowrap valign=&quot;top&quot; height=&quot;22&quot;> </td>
<td valign=&quot;top&quot; height=&quot;22&quot; width=&quot;100%&quot;><font face=&quot;times new roman, times&quot; size=&quot;4&quot; color=&quot;#ffffff&quot; style=&quot;text-decoration: none;&quot;><b>
<% = strTempNAME %>
</b></font></td>
<td height=&quot;22&quot;> </td>
</tr>
<tr>
<td height=&quot;27&quot; valign=&quot;bottom&quot;> </td>
<td height=&quot;27&quot; colspan=&quot;4&quot; valign=&quot;bottom&quot;>
<div align=&quot;right&quot;><font face=&quot;arial&quot; size=&quot;2&quot; color=&quot;#CC3300&quot;> <b>
<% = recProduct(&quot;STYLES&quot;) %>
</b></font></div>
</td>
</tr>
<tr>
<td height=&quot;21&quot;> </td>
<td height=&quot;21&quot;> </td>
<td nowrap valign=&quot;top&quot; height=&quot;21&quot; colspan=&quot;3&quot;> </td>
</tr>
<tr>
<td height=&quot;250&quot;> </td>
<td height=&quot;250&quot;>
<p>
<% if (recProduct(&quot;PICTUREURL&quot;).ActualSize > 0) then %>
<img src=&quot;<% = recProduct(&quot;PICTUREURL&quot;) %>&quot; width=&quot;200&quot; height=&quot;250&quot; hspace=&quot;0&quot; border=&quot;0&quot; alt=&quot;<% = strTempNAME %>&quot;></p>
<p> </p>
</td>
<td nowrap valign=&quot;top&quot;>    </td>
<td valign=&quot;top&quot; height=&quot;250&quot; width=&quot;100%&quot;>
<% end if %>
<table align=&quot;center&quot; border=&quot;0&quot; cellpadding=&quot;2&quot; cellspacing=&quot;0&quot; width=&quot;100%&quot; height=&quot;250&quot;>
<tr>
<td height=&quot;200&quot; valign=&quot;top&quot;>
<form name=&quot;form1&quot; method=&quot;post&quot; action=&quot;/sendmsg.asp?command=<% = Server.URLEncode(&quot;/secure/editcart.asp?action=additem&pid=39&quot;)%>&quot; target=&quot;_parent&quot;>
<font face=&quot;arial&quot; size=&quot;2&quot; color=&quot;#000000&quot;>
<% = recProduct(&quot;DESCRIPTION&quot;) %>
</font><br><br>
<font face=&quot;arial&quot; size=&quot;2&quot; color=&quot;#000000&quot;>
<%if (recProduct(&quot;Prodmultiple&quot;)) then %>
<input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;Submit&quot;>
<%Else%>
<a href=&quot;/sendmsg.asp?command=<% = Server.URLEncode(&quot;/secure/editcart.asp?action=additem&pid=&quot; & intTempUID)%>&quot; target=&quot;_parent&quot;>Buy
this item</a>
<%End IF%>
</font>
<%if (recProduct(&quot;Prodmultiple&quot;)) then
dim NameTemp
dim recVersion
NameTemp = recProduct(&quot;Name&quot;)

set recVersion = Server.CreateObject(&quot;ADODB.Recordset&quot;)
recVersion.ActiveConnection = &quot;DRIVER=Microsoft Access Driver (*.mdb);FIL=MS Access;DBQ=&quot; & Server.MapPath(&quot;/database/20010208.mdb&quot;)&&quot;&quot;
recVersion.Source = &quot;SELECT * FROM queryPRODUCTLIST WHERE Name like '&quot; + NameTemp + &quot;'ORDER BY STYLES ASC &quot;
recVersion.CursorType = 0
recVersion.CursorLocation = 2
recVersion.LockType = 3
recVersion.Open()

%>
<select name=&quot;select&quot; onChange=&quot;updatePID(this)&quot;>
<%
While (NOT recVersion.EOF)
%>
<option value=&quot;<%=(recVersion.Fields.Item(&quot;ID&quot;).Value)%>&quot; <%if (CStr(recVersion.Fields.Item(&quot;ID&quot;).Value) = CStr(recProduct.Fields.Item(&quot;ID&quot;).Value)) then Response.Write(&quot;SELECTED&quot;) : Response.Write(&quot;&quot;)%>><%=(recVersion.Fields.Item(&quot;STYLES&quot;).Value)%></option>
<%
recVersion.MoveNext()
Wend
If (recVersion.CursorType > 0) Then
recVersion.MoveFirst
Else
recVersion.Requery
End If
%>
</select>
<%End If%>
</form>
</td>
</tr>
<tr>
<td align=&quot;right&quot; valign=&quot;top&quot; height=&quot;20&quot;><font face=&quot;arial&quot; size=&quot;2&quot; color=&quot;#000000&quot;><b>-
<a href=&quot;javascript:window.close();&quot; onMouseOver=&quot;window.status='Close'; return true;&quot;>Close</a>
-</b></font></td>
</tr>
</table>
</td>
<td>
<%
recProduct.Close
else
%>
<font color=&quot;#000000&quot; face=&quot;verdana, arial&quot; size=&quot;2&quot; style=&quot;font-size: 11px;&quot;>The
requested product could not be found in the product catalog.</font>
<%
end if
adoDBConnect.Close
else
%>
<font color=&quot;#000000&quot; face=&quot;verdana, arial&quot; size=&quot;2&quot; style=&quot;font-size: 11px;&quot;>The
requested product could not be found in the product catalog.</font>
<%
end if
%>
</td>
</tr>
</table>
</body>
 
Stick this in a blank page and see if it helps you.
<script>
function produceurl()
{
if (radio[0].checked == true)
{
//href.location =' alert('You would have been sent to }
if (radio[1].checked == true)
{
//href.location =' alert('You would have been sent to }
if (radio[2].checked == true)
{
//href.location =' alert('You would have been sent to }
}
</script>
<body>
<input type=radio name=radio value=1> <input type=radio name=radio value=2> <input type=radio name=radio value=3> <input type=button value=Submit onclick=produceurl()>
</body>


if not call me, DeltaFlyer ;-)

DeltaFlyer - The Only Programmer To Crash With Style.
 
Thanks, I like the idea. It is along the lines of something I tried. The problem is that this page is a details page that will have many, maybe even a couple of hundred, different items to display. Some with several different choices. I guess I would have to create a dynamic array and create the URl that way.

What I was thinking is that I create a function that changes the value of a variable when the choice in the menu is changed. In the url I would just tack on the variable. The problem is that I do not know how to attach the variable.

One problem that I ran into was that I needed an onclick event in the URL that retrieved the entire url. The problem is that I am not great with JavaScript so I do not understand how to do it.

Blah. I don't know.
 
Have you got a rough draught of what the page is meant to look like, i.e. HTML only?? If so then i may be able to help you come up with a solution.

If not is you could throw one together and dump it on here then i will probaly be able to help you.

Catchya later, DeltaFlyer
The Only Programmer To Crash With Style. LOL
 
I appreciate the help but I am not sure what you mean. The code is above so would you like to see an image of the page?
 
You said that there were possiby many hundreds of select boxes that would be included. However if you want to do the dynamic array thing then all you would have to do is using the onclick javascript populate a hidden text box with the overall variable and then with javascript do a window.location = &quot; + document.form.hidden.value and that would push all your variables through to the next page. DeltaFlyer
The Only Programmer To Crash With Style. LOL
 
I don't think I explained myself very well. This page displays info regarding products selected on a previous page. Some products have only one subtype while others have multiple subtypes.

When a product has multiple subtypes the user must be able to choose which one they want by using a drop down menu. This value then needs to be passed onto the next page which is the shopping cart info page via an html link.

The problem for me is how do I get the value from the menu into the url. I think the problem is the combination of Vb and javascript.

Here is the code for the link that works.

<a href=&quot;/sendmsg.asp?command=<% = Server.URLEncode(&quot;/secure/editcart.asp?action=additem&pid=&quot; & intTempUID)%>&quot; target=&quot;_parent&quot;>Buy this item</a>

intTempUID is a vbscript variable.

I think I need to do something similar to what has been done here. By this I mean use a variable initially set to the value of the initial subtype of product. I then need an onChange function to monitor the menu to see if it changes.

This is where I fall apart. I want to use the javascript onChange() function, therefore a javascript variable, but I have no idea hoe to attach this variable to the URL because it has vbscript in it.

Well DeltaFlyer, if you have continued to read this rambling message then thank you and if you can help thank you infinitely.

trc
 
trc

Try this on:

If you set a global variable &quot;url_start&quot; to be something like &quot; and another global &quot;url_end&quot; (only if you need it) then you can use:

<select onChange=&quot;url_start = url_start + this.options[selectedIndex].value;&quot;> // the value of whatever item is selected here gets concatenated with your base URL
<option value=&quot;red_thing&quot;>Red Thing
<optoin value=&quot;blue_thing&quot;>Blue Thing
</select>

Then for your Buy link:
<a href=&quot;javascript:window.location.href=url_start + url_end;&quot;>Buy this</a>

Hope this helps,
johnny
 
Thank you. I think that might work. I will give it a try.
 
I tried what you suggested but it did not work. Thanks anyway. The problem is the mix of javascript and vbscript in the url.

<a href=&quot;/sendmsg.asp?command=<%= Server.URLEncode (&quot;/secure/editcart.asp?action=additem&pid=&quot; & vbSelect_ID)%>&quot; target=&quot;_parent&quot;> this item</a>

I am close. I can set the intitial value. Then I amtrying to use javasrcipt/vbscript function calls to set the new value. But I cannot set the value once the option is selected. I keep getting an &quot;Object Expected&quot; error. Any suggestion would be appreciated.

Here is the code.

<script language=&quot;JavaScript&quot;>
function jsGetValue(jsSel_val){
vbSetValue(jsSel_val)
}
</script>

<%

Function vbSetValue(vbSelVal)
vbSelect_ID=vbSelVal
End Function
%>


<select name=&quot;Select&quot; onChange=&quot;jsGetValue(this.options.value);&quot;>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top