get values from dynamic dropdown (Full Version)

All Forums >> [Web Development] >> Microsoft FrontPage Help



Message


BerylSmall -> get values from dynamic dropdown (8/14/2005 16:15:34)

This probably sounds dumb but I'm new to this.
Okay, I have created two dynamic dropdowns inside of my DRW. (I'm making an e-commerce site that posts to a shopping cart). The code for the dropdowns are as follows:

<%
Response.Write "<p><strong>Color:</strong>  <select name='Option' ID='Color' Size='1'>"
Set rsSample = Server.CreateObject("ADODB.Recordset")
rsSample.Open "Select Distinct Color from Query1 where Products.Style='" & FP_FieldVal(fp_rs,"Style") & "'", fp_conn
While not rsSample.EOF
Response.Write "<option>" & rsSample.Fields("Color") & "</option>"
rsSample.MoveNext
Wend
rsSample.Close
Response.Write "</select><br>"
%>
<%
Response.Write "<p><strong>Size:</strong>  <select name='Option' ID='Size' Size='1'>"
Set rsSample = Server.CreateObject("ADODB.Recordset")
rsSample.Open "Select Distinct Garment_Size from Query1 where Products.Style='" & FP_FieldVal(fp_rs,"Style") & "' ORDER BY Garment_Size ASC", fp_conn
While not rsSample.EOF
Response.Write "<option>" & rsSample.Fields("Garment_Size") & "</option>"
rsSample.MoveNext
Wend
rsSample.Close
Response.Write "</select><br>"
%>
The dropdowns work great. The problem is, I need to get the selected values appended to my hyperlink on my Add to cart button. I know how to get the DRW values using <%=FP_FieldVal(fp_rs,"Style")%>, but how do I refer to the selected options in each dropdown box?




Spooky -> RE: get values from dynamic dropdown (8/14/2005 16:33:46)

Is the add to cart button hard coded as a link or does it "POST" to the next page. How does that button work?




BerylSmall -> RE: get values from dynamic dropdown (8/14/2005 16:47:01)

It's hardcoded as a link:
<a href="http://ww9.aitsafe.com/cf/add.cfm?userid=B828873&product=<%=FP_FieldVal(fp_rs,"Description")%>&price=<%=FP_FieldVal(fp_rs,"Retail_Price")%>&qty=1"><img border="0" src="../images/ADDButton.gif"></a>




Spooky -> RE: get values from dynamic dropdown (8/14/2005 17:02:15)

If using form elements, then youll need to convert the link to a posting form (using GET or POST) so that you get access to the drop downs.
So, each item will have a form action of http://ww9.aitsafe.com/cf/add.cfm and a method of GET (so it uses the same querystring method as you have)




BerylSmall -> RE: get values from dynamic dropdown (8/14/2005 17:09:48)

I don't get it. Do I put the DRW inside a Form? And if so, then how would I refer to the fields in the DRW? And still...how would I refer to the selected values in the dropdown boxes?




Spooky -> RE: get values from dynamic dropdown (8/14/2005 17:49:30)

Currently you are using the DRW to pull items from the database.
For each item you display, you are dynamically writing the hyperlink for that item as the "add to cart" button.

Is that correct?




BerylSmall -> RE: get values from dynamic dropdown (8/14/2005 17:56:07)

yes, that is correct.




Spooky -> RE: get values from dynamic dropdown (8/14/2005 18:06:21)

Inside that loop of the DRW, you would need to add the form tags something like this :

<form method=GET Action="http://ww9.aitsafe.com/cf/add.cfm">
<input type=hidden value="B828873" name="userid">
<input type=hidden value="<%=FP_FieldVal(fp_rs,"Description")%>" name="product">
<input type=hidden value="<%=FP_FieldVal(fp_rs,"Retail_Price")%>" name="price">
<input type=hidden value="1" name="qty">

## Other drop downs

<input type=submit>
</form>




BerylSmall -> RE: get values from dynamic dropdown (8/14/2005 18:34:17)

Okay, now you've really lost me..
You say inside the loops of the DRW...The only loops that I know of in the DRW are the loops that populate the dropdowns. I should put that code in there?




BerylSmall -> RE: get values from dynamic dropdown (8/14/2005 18:37:31)

I'm really confused now...Am I putting a form inside the DRW? When I do insert Form I get these submit buttons (that I don't need) and then what happens to my add to cart button? And I still don't see where I'm getting the values from my dropdowns (Size and Color) they are missing from the form code there. I don't get this at all...




Spooky -> RE: get values from dynamic dropdown (8/14/2005 20:30:26)

Are you able to post the code as above " Currently you are using the DRW to pull items from the database. "

By this - I mean the actual items you are selling. They are from a DRW?
Then - you also populate the drop down lists

Are you able to post the code you are using?




BerylSmall -> RE: get values from dynamic dropdown (8/14/2005 20:33:54)

Yes, I can post the code, but the values from the dropdowns are not including because I don't know how to refer to them.




Spooky -> RE: get values from dynamic dropdown (8/14/2005 21:09:05)

Post that code anyway (without the drop downs)




BerylSmall -> RE: get values from dynamic dropdown (8/14/2005 21:21:27)

quote:

<a href="http://ww9.aitsafe.com/cf/add.cfm?userid=B828873&product=<%=FP_FieldVal(fp_rs,"Description")%>&price=<%=FP_FieldVal(fp_rs,"Retail_Price")%>&qty=1"><img border="0" src="../images/ADDButton.gif"></a>


and

<form method=GET Action="http://ww9.aitsafe.com/cf/add.cfm">
<input type=hidden value="B828873" name="userid">
<input type=hidden value="<%=FP_FieldVal(fp_rs,"Description")%>" name="product">
<input type=hidden value="<%=FP_FieldVal(fp_rs,"Retail_Price")%>" name="price">
<input type=hidden value="1" name="qty">
<input type=submit>
</form>

Both work. But how do I get the dropdowns in either one?




Spooky -> RE: get values from dynamic dropdown (8/14/2005 21:35:47)

So, as a test, do this :

<form method=GET Action="http://ww9.aitsafe.com/cf/add.cfm">
<input type=hidden value="B828873" name="userid">
<input type=hidden value="<%=FP_FieldVal(fp_rs,"Description")%>" name="product">
<input type=hidden value="<%=FP_FieldVal(fp_rs,"Retail_Price")%>" name="price">
<input type=hidden value="1" name="qty">

<select name='Size' Size='1'>
<option>Your size 1</option>
<option>Your size 2</option>
</select>

<select name='Color' Size='1'>
<option>Your Color 1</option>
<option>Your Color 2</option>
</select>

<input type=submit>
</form> 


When you post this item to http://ww9.aitsafe.com/cf/add.cfm, the value "Size" (from the drop down name) will contain one of your selections.
This assumes that the page "/add.cfm" has the ability to receive that value

Is the page "/add.cfm" accessible to you, or is it a processing page belonging to your shop provider?
Are you able to get it to accept "Size" as a value?









BerylSmall -> RE: get values from dynamic dropdown (8/14/2005 21:50:06)

No, it does not belong to me and it doesn't take "Size". I have to concatenate it with the product. This is a sample that works (but of course it is not dynamic):

<form action="http://www.aitsafe.com/cf/add.cfm" method="post">
<input type="hidden" name="userid" value="malc">
<input type="hidden" name="return" value="www.mals-e.com/help7.cfm">
<table width="100%" border="0" bgcolor="#f5f5f5">
<tr><td width="80%">
Musto Oceanmaster sailing jacket.  <b>Price: $159.00</b><br>
Select your size : 
<input type="hidden" name="product[]" value="Oceanmaster jacket">
<select name="product[]">
<option value="Small">Small</option>
<option value="Medium">Medium</option>
<option value="Large">Large</option>
<option value="X-Large">X-Large</option>
</select>
Color : 
<select name="product[]">
<option value="Red">Red</option>
<option value="Navy">Navy</option>
<option value="Green">Green</option>
</select>								
</td>
<td>
<input type="hidden" name="price" value="159">
<input type="submit" value="Buy Now!">
</td>
</tr>
</table>
</form>	





Spooky -> RE: get values from dynamic dropdown (8/14/2005 22:10:38)

So you would need to do the same as below?
What I want to see - is first ensure that you are passing the correct information to the processing page. Then, after that we can worry about making them dynamic

<form method=GET Action="http://ww9.aitsafe.com/cf/add.cfm">
<input type=hidden value="B828873" name="userid">
<input type=hidden value="<%=FP_FieldVal(fp_rs,"Description")%>" name="product">
<input type=hidden value="<%=FP_FieldVal(fp_rs,"Retail_Price")%>" name="price">
<input type=hidden value="1" name="qty">

<select name='Product[]' Size='1'>
<option>Your size 1</option>
<option>Your size 2</option>
</select>

<select name='Product[]' Size='1'>
<option>Your Color 1</option>
<option>Your Color 2</option>
</select>

<input type=submit>
</form> 




Spooky -> RE: get values from dynamic dropdown (8/14/2005 22:34:30)

Should it be :

<select name='Product[]' Size='1'>

Or :

<select name='Product' Size='1'> ?




BerylSmall -> RE: get values from dynamic dropdown (8/14/2005 23:23:05)

The options in the above "test" do not show in the cart either.




Spooky -> RE: get values from dynamic dropdown (8/14/2005 23:49:00)

If you use your existing link :

<a href="http://ww9.aitsafe.com/cf/add.cfm?userid=B828873&product=<%=FP_FieldVal(fp_rs,"Description")%>&price=<%=FP_FieldVal(fp_rs,"Retail_Price")%>&qty=1"><img border="0" src="../images/ADDButton.gif"></a>


How would you normally add a size to this if you were hard coding it? (dont worry about the lists for now)
Do you have an example on how adding additional options works? and you can test that it works by adding it to your URL above?




BerylSmall -> RE: get values from dynamic dropdown (8/14/2005 23:52:34)

Okay, I tried the following the "Size" is dynamic, but the "Color" is not. The Size does NOT show up in the cart, but the Color does....

<form action="http://ww9.aitsafe.com/cf/add.cfm" method="post">
		<input type="hidden" name="userid" value="B828873">
		<input type="hidden" name="return" value="http://localhost/Test2/test.asp">
<table width="100%" border="0" bgcolor="#f5f5f5">
<tr>
<td width="80%">
</b><br>
Select your size : 
<input type="hidden" name="product[]" value="<%=FP_FieldVal(fp_rs,"Description")%>">
<select name="Product[]" Size='1'>
<%Set rsSample = Server.CreateObject("ADODB.Recordset")
rsSample.Open "Select Distinct Garment_Size from Query1 where Products.Style='" & FP_FieldVal(fp_rs,"Style") & "' ORDER BY Garment_Size ASC", fp_conn
While not rsSample.EOF
Response.Write "<option value=" & rsSample.Fields("Garment_Size") & ">" & rsSample.Fields("Garment_Size") & "</option>"
rsSample.MoveNext
Wend
rsSample.Close%>
</select><br>"
      
Color : 
<select name="product[]">
<option value="Red">Red</option>
<option value="Navy">Navy</option>
<option value="Green">Green</option>
</select>								
</td>
<td>
<input type="hidden" name="price" value="<%=FP_FieldVal(fp_rs,"Retail_Price")%>">
<input type="submit" value="Buy Now!">
</td>
</tr>
</table>
		
</form>




Spooky -> RE: get values from dynamic dropdown (8/14/2005 23:55:42)

Try this?

 <select name="product[]" Size="1">
<%Set rsSample = Server.CreateObject("ADODB.Recordset")
rsSample.Open "Select Distinct Garment_Size from Query1 where Products.Style='" & FP_FieldVal(fp_rs,"Style") & "' ORDER BY Garment_Size ASC", fp_conn
While not rsSample.EOF
Response.Write "<option value=""" & rsSample.Fields("Garment_Size") & """>" & rsSample.Fields("Garment_Size") & "</option>"
rsSample.MoveNext
Wend
rsSample.Close%>
</select><br>" 





BerylSmall -> RE: get values from dynamic dropdown (8/15/2005 0:10:45)

Nope...Color, No Size




Spooky -> RE: get values from dynamic dropdown (8/15/2005 0:42:16)

Without knowing the format it requires - its hard to say.

We have presented the purchase page with the options in a format that is demonstrated above in the sample.
Is there a specific "text" it expects to judge the size? eg "small, medium, large" ?

If you dont use the dynamic example - does the hard coded version from the sample work?

 <select name="product[]">
<option value="Small">Small</option>
<option value="Medium">Medium</option>
<option value="Large">Large</option>
<option value="X-Large">X-Large</option>
</select>





BerylSmall -> RE: get values from dynamic dropdown (8/15/2005 0:45:21)

Using the Hyperlink below, I can add the word 'Test' to the product description, and it shows up in the cart. I there a way for me to get value of the option into text so that I can just add it to the hyperlink?

"http://ww9.aitsafe.com/cf/add.cfm?userid=B828873&product=<%=FP_FieldVal(fp_rs,"Description")%>+'Test'&price=<%=FP_FieldVal(fp_rs,"Retail_Price")%>"><img border="0" src="../images/ADDButton.gif"></a>




BerylSmall -> RE: get values from dynamic dropdown (8/15/2005 0:46:23)

Yes, if I use hard coded options, they work. Only the dynamic doesn't.




Spooky -> RE: get values from dynamic dropdown (8/15/2005 0:52:45)

Can you show me the source code from the browser for that page? (with the dynamic drop down)

ie - view the purchase page in your browser and then view > source.
Post the contents here




Spooky -> RE: get values from dynamic dropdown (8/15/2005 0:58:26)

quote:

I there a way for me to get value of the option into text so that I can just add it to the hyperlink

No - the problem remains that you cant select it from the drop down and have it used with the link.
Another option is that you could have 'x' number of links for each size - "small, medium,large"
It really depends on the design of the page, if you want seperate links.

However - i think we are very close to getting the drop down working?




Spooky -> RE: get values from dynamic dropdown (8/15/2005 1:01:13)

No - from the product page, the one with the drop downs?




BerylSmall -> RE: get values from dynamic dropdown (8/15/2005 1:06:58)

<table width="898" border="1">
  <thead>
    <tr>
      <td width="165"><b>Picture</b></td>
      <td width="137"><b>Style</b></td>
      <td width="66"><b>Color</b></td>
      <td width="65"><b>Size</b></td>
      <td width="225"> </td>
      <td width="225"><b>Description</b></td>
      <td width="132"><b>Retail_Price</b></td>
      <td width="78">Add to Cart</td>
    </tr>
  </thead>
  <tbody>
    <!--webbot bot="DatabaseRegionStart" startspan
    s-columnnames="Style,Description,Picture,Retail_Price"
    s-columntypes="202,202,203,6" s-dataconnection="Products"
    b-tableformat="TRUE" b-menuformat="FALSE" s-menuchoice s-menuvalue
    b-tableborder="TRUE" b-tableexpand="TRUE" b-tableheader="TRUE"
    b-listlabels="TRUE" b-listseparator="TRUE" i-ListFormat="0"
    b-makeform="TRUE" s-recordsource
    s-displaycolumns="Picture,Style,Description,Retail_Price" s-criteria s-order
    s-sql="SELECT Distinct Products.Style,Description,Picture,Retail_Price FROM Query1"
    b-procedure="FALSE" clientside SuggestedExt="asp" s-DefaultFields
    s-NoRecordsFound="No records returned." i-MaxRecords="256" i-GroupSize="5"
    BOTID="0" u-dblib="../_fpclass/fpdblib.inc" u-dbrgn1="../_fpclass/fpdbrgn1.inc"
    u-dbrgn2="../_fpclass/fpdbrgn2.inc" tag="TBODY"
    local_preview="<tr><td colspan=64 bgcolor="#FFFF00" align="left" width="100%"><font color="#000000">Database Results regions will not preview unless this page is fetched from a Web server with a web browser. The following table row will repeat once for every record returned by the query.</font></td></tr>"
    preview="<tr><td colspan=64 bgcolor="#FFFF00" align="left" width="100%"><font color="#000000">This is the start of a Database Results region.</font></td></tr>" --><!--#include file="../_fpclass/fpdblib.inc"-->
<%
fp_sQry="SELECT Distinct Products.Style,Description,Picture,Retail_Price FROM Query1"
fp_sDefault=""
fp_sNoRecords="<tr><td colspan=4 align=left width=""100%"">No records returned.</td></tr>"
fp_sDataConn="Products"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=5
fp_fTableFormat=True
fp_fMenuFormat=False
fp_sMenuChoice=""
fp_sMenuValue=""
fp_iDisplayCols=4
fp_fCustomQuery=True
BOTID=0
fp_iRegion=BOTID
%>
<!--#include file="../_fpclass/fpdbrgn1.inc"-->
<!--webbot bot="DatabaseRegionStart" i-CheckSum="43172" endspan -->
    <tr>
      <td width="165"><a href="ProductPage.asp?Style=<%=FP_FieldURL(fp_rs,"Style")%>"><img border="0" src="<%=FP_FieldLink(fp_rs,"Picture")%>" width="250" height="250">
        </a>
      </td>
      <td width="137"><!--webbot bot="DatabaseResultColumn" startspan
        s-columnnames="Style,Description,Picture,Retail_Price" s-column="Style"
        b-tableformat="TRUE" b-hasHTML="FALSE" clientside
        local_preview="<font size="-1"><<</font>Style<font size="-1">>></font>"
        preview="<font size="-1"><<</font>Style<font size="-1">>></font>" --><%=FP_FieldVal(fp_rs,"Style")%><!--webbot
        bot="DatabaseResultColumn" i-CheckSum="10122" endspan -->
      </td>
      <td width="66"><!--webbot bot="HTMLMarkup" startspan --><%
         Response.Write "<p><strong>Color:</strong>  <select name='Product' ID='Color' Size='1'>"
         Set rsSample = Server.CreateObject("ADODB.Recordset")
         rsSample.Open "Select Distinct Color from Query1 where Products.Style='" & FP_FieldVal(fp_rs,"Style") & "'", fp_conn
         While not rsSample.EOF
           Response.Write "<option>" & rsSample.Fields("Color") & "</option>"
         rsSample.MoveNext
         Wend
         rsSample.Close
         Response.Write "</select><br>"
      %>
<!--webbot bot="HTMLMarkup" endspan -->
      </td>
      <td width="65"><!--webbot bot="HTMLMarkup" startspan --><%
         Response.Write "<p><strong>Size:</strong>  <select name='Product' ID='Size' Size='1'>"
         Set rsSample = Server.CreateObject("ADODB.Recordset")
         rsSample.Open "Select Distinct Garment_Size from Query1 where Products.Style='" & FP_FieldVal(fp_rs,"Style") & "' ORDER BY Garment_Size ASC", fp_conn
         While not rsSample.EOF
           Response.Write "<option>" & rsSample.Fields("Garment_Size") & "</option>"
         rsSample.MoveNext
         Wend
         rsSample.Close
         Response.Write "</select><br>"
      %>
<!--webbot bot="HTMLMarkup" endspan -->
      </td>
      <td width="225"><!--webbot bot="HTMLMarkup" startspan -->
      <a href="http://ww9.aitsafe.com/cf/add.cfm?userid=B828873&product=<%=FP_FieldVal(fp_rs,"Description")%>+'Test'&price=<%=FP_FieldVal(fp_rs,"Retail_Price")%>"><img border="0" src="../images/ADDButton.gif"></a>
      <!--webbot
        bot="HTMLMarkup" endspan -->
      </td>
      <td width="225"><!--webbot bot="DatabaseResultColumn" startspan
        s-columnnames="Style,Description,Picture,Retail_Price"
        s-column="Description" b-tableformat="TRUE" b-hasHTML="FALSE" clientside
        local_preview="<font size="-1"><<</font>Description<font size="-1">>></font>"
        preview="<font size="-1"><<</font>Description<font size="-1">>></font>" --><%=FP_FieldVal(fp_rs,"Description")%><!--webbot
        bot="DatabaseResultColumn" i-CheckSum="30092" endspan -->
      </td>
      <td width="132"><!--webbot bot="DatabaseResultColumn" startspan
        s-columnnames="Style,Description,Picture,Retail_Price"
        s-column="Retail_Price" b-tableformat="TRUE" b-hasHTML="FALSE"
        clientside
        local_preview="<font size="-1"><<</font>Retail_Price<font size="-1">>></font>"
        preview="<font size="-1"><<</font>Retail_Price<font size="-1">>></font>" --><%=FP_FieldVal(fp_rs,"Retail_Price")%><!--webbot
        bot="DatabaseResultColumn" i-CheckSum="31068" endspan -->
      </td>
      <td width="78"><form action="http://ww9.aitsafe.com/cf/add.cfm" method="post">
		<input type="hidden" name="userid" value="B828873">
		<input type="hidden" name="return" value="http://localhost/Test2/applebottoms.asp">
		
		<table width="100%" border="0" bgcolor="#f5f5f5">
		<tr>
			<td width="80%">
			
				Select your size : 
				<input type="hidden" name="product[]" value="<%=FP_FieldVal(fp_rs,"Description")%>">
				<select name="Product[]" Size='1'>
         <%Set rsSample = Server.CreateObject("ADODB.Recordset")
rsSample.Open "Select Distinct Garment_Size from Query1 where Products.Style='" & FP_FieldVal(fp_rs,"Style") & "' ORDER BY Garment_Size ASC", fp_conn
While not rsSample.EOF
Response.Write "<option value=" & rsSample.Fields("Garment_Size") & ">" & rsSample.Fields("Garment_Size") & "</option>"
rsSample.MoveNext
Wend
rsSample.Close%>
</select><br>
Color : 
				<select name="product[]">
					<option value="Red">Red</option>
					<option value="Navy">Navy</option>
					<option value="Green">Green</option>
				</select>								
			</td>
			<td>
				<input type="hidden" name="price" value="<%=FP_FieldVal(fp_rs,"Retail_Price")%>">
				<input type="submit" value="Buy Now!">
			</td>
		</tr>
		</table>
		
		</form>	 </td>
    </tr>
    <!--webbot bot="DatabaseRegionEnd" startspan b-tableformat="TRUE"
    b-menuformat="FALSE" u-dbrgn2="../_fpclass/fpdbrgn2.inc" i-groupsize="5"
    clientside tag="TBODY"
    local_preview="<tr><td colspan=64 bgcolor="#FFFF00" align="left" width="100%"><font color="#000000">This is the end of a Database Results region.</font></td></tr><TR><TD ALIGN=LEFT VALIGN=MIDDLE COLSPAN=64><FORM><NOBR><INPUT TYPE=Button VALUE="  |<  "><INPUT TYPE=Button VALUE="   <  "><INPUT TYPE=Button VALUE="  >   "><INPUT TYPE=Button VALUE="  >|  ">  [1/5]</NOBR></FORM></td></tr>"
    preview="<tr><td colspan=64 bgcolor="#FFFF00" align="left" width="100%"><font color="#000000">This is the end of a Database Results region.</font></td></tr><TR><TD ALIGN=LEFT VALIGN=MIDDLE COLSPAN=64><NOBR><INPUT TYPE=Button VALUE="  |<  "><INPUT TYPE=Button VALUE="   <  "><INPUT TYPE=Button VALUE="  >   "><INPUT TYPE=Button VALUE="  >|  ">  [1/5]</NOBR><BR></td></tr>" --><!--#include file="../_fpclass/fpdbrgn2.inc"-->
<!--webbot bot="DatabaseRegionEnd" i-CheckSum="56926" endspan -->
  </tbody>
</table>

</body>




Page: [1] 2   next >   >>

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.140625