Forum Moderators: open

Message Too Old, No Replies

List box connected to database

problems getting it to work

         

Andrew Thomas

2:06 pm on Mar 26, 2002 (gmt 0)

10+ Year Member



Can someone tell me what to do....

<select name="select">
<%
while (!Recordset1.EOF)
{
%>
<option value="<%=(Recordset1.Fields.Item("URL").Value)%>" ><%=(Recordset1.Fields.Item("URL").Value)%></option>
<%
Recordset1.MoveNext();
}
if (Recordset1.CursorType > 0) {
if (!Recordset1.BOF) Recordset1.MoveFirst();
} else {
Recordset1.Requery();
}
%>
</select>

<input type="submit" name="submit" value="submit">

<DIV id="iframeContainer" style="position:absolute; left:23px; top:10px; width:970px; height:153px; visibility:visible;">
<IFRAME src="<%=(Recordset1.Fields.Item("URL").Value)%>" border=0 frameborder=0 marginheight=0 marginwidth=0 width="100%" height="100%" name="iframeElement" id="iframeElement" scrolling=none>
</IFRAME> </DIV>

I have a database of URLS which connects to a list box. Once the URL is selected from the list box, i want the URL to appear in the IFRAME, this works for the first url, but then after nothing happens, i know its to do with the submit button value, but im not sure what should go in here. thanks

korkus2000

3:50 pm on Mar 26, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What does your form tag look like?

BlobFisk

4:14 pm on Mar 26, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In the IFRAME should the src not be reading from the list item the user selected, as opposed to something from the Recordset?

That's just a guess, korkus200 was right to ask about the <FORM> code before saying anything!

:)

Andrew Thomas

4:27 pm on Mar 26, 2002 (gmt 0)

10+ Year Member



<form name="form1" method="post" action="">

Like i said, im a bit stuck on what to do..

help....

korkus2000

4:35 pm on Mar 26, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I would send it to a page or to itself and grap the querystring or form post variables.

FormSelectVar = select.value;

then

IFRAME src="<%=FormSelectVar%>"

I would also make the select box option selected that is the current value to keep state.

<select name="select">
<%
while (!Recordset1.EOF)
{
%>
<option value="<%=(Recordset1.Fields.Item("URL").Value)%>"

<% if (Recordset1.Fields.Item("URL").Value == FormSelectVar){
%>
SELECTED
<%
}
%>

><%=(Recordset1.Fields.Item("URL").Value)%></option>
<%
Recordset1.MoveNext();
}
if (Recordset1.CursorType > 0) {
if (!Recordset1.BOF) Recordset1.MoveFirst();
} else {
Recordset1.Requery();
}
%>
</select>

I would try something like that. There are plenty of ways to do it. Be kind to your visitor and keep their state.

Andrew Thomas

5:02 pm on Mar 26, 2002 (gmt 0)

10+ Year Member



Thanks korkus i'll give it a try..

Andrew Thomas

5:20 pm on Mar 26, 2002 (gmt 0)

10+ Year Member



Sorry for being dumb!

But what does this correspond to?

FormSelectVar = select.value;

Im a bit new to all this..

korkus2000

6:28 pm on Mar 26, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<form name="searchForm" method="get" action="pagename">

When you submit this it will pass a query string to "pagename". On "pagename"
Request the query string parameters.

Request.Querystring("select")

this will give you the value of your select name value pair in the query string.

pagename?select=URL

assign the value of your select form field to a variable.

FormSelectVar = Request.Querystring("select")

You will then have that variable containing your url for the life of the page.

Use your variable any where on the page where you want to display the last choice of a form post.

My syntax is probably wrong, but that is what you need to get your task done.