Easy question - Trouble with Request.Form

R

Rabel

I am new to asp and I am having a little trouble with the Request.form
option. What I want to do is I have a dropdown box.

<select name="selecter" class="text" id="selecter">
<option value="page1.htm" selected>Page 1</option>
<option value="page2.htm">Page 2</option>
<option value="page3.htm">Page 3</option>
</select>

and I want to use a button that then will take you to the page you
selected so I have been trying codes like this.

<a href="<%= Request.Form("selecter") %>" ><img src="submit.jpg"
width="45" height="18" border="0"></a>

Any idea what I am doing wrong, any help is apprieciated.

Thanks,
Randy
 
M

Marc

Rabel said:
I am new to asp and I am having a little trouble with the Request.form
option. What I want to do is I have a dropdown box.

<select name="selecter" class="text" id="selecter">
<option value="page1.htm" selected>Page 1</option>
<option value="page2.htm">Page 2</option>
<option value="page3.htm">Page 3</option>
</select>

and I want to use a button that then will take you to the page you
selected so I have been trying codes like this.

<a href="<%= Request.Form("selecter") %>" ><img src="submit.jpg"
width="45" height="18" border="0"></a>

Any idea what I am doing wrong, any help is apprieciated.

Thanks,
Randy

I think you want to try javascript for that but...


<%
Response.Redirect(Request.Form("selecter"))
%>
 
M

Marc

Marc said:
I think you want to try javascript for that but...


<%
Response.Redirect(Request.Form("selecter"))
%>
I can't help myself:

<select name="selecter" class="text" id="selecter"
onchange="if(this.selectedIndex>0)document.location.href=this.options[this.selectedIndex].value">
<option value="" selected>Select page</option>
<option value="page1.htm">Page 1</option>
<option value="page2.htm">Page 2</option>
<option value="page3.htm">Page 3</option>
</select>

Make sure the "onchange" bit until the ">" is on one line!
 
R

Rabel

I think you want to try javascript for that but...
<%
Response.Redirect(Request.Form("selecter"))
%>

I can't help myself:

<select name="selecter" class="text" id="selecter"
onchange="if(this.selectedIndex>0)document.location.href=this.options[this.­selectedIndex].value">
<option value="" selected>Select page</option>
<option value="page1.htm">Page 1</option>
<option value="page2.htm">Page 2</option>
<option value="page3.htm">Page 3</option>
</select>

Make sure the "onchange" bit until the ">" is on one line!- Hide quoted text -

- Show quoted text -

Thanks Marc - but is there a way that I can still use a button then
just when you select from the box.

Thanks
 
R

Rabel

You need to have a default value for your link until the user makes a selection

and

-- you either need an autopostabck on your selector which will then change the link value

or

-- you need to use javascript to change the link value based upon the user selection.










- Show quoted text -

Thanks Jon but I dont really understand what you mean - I think that
you are describing Marc's js version which I am using but I would
still like to have a button make it go to the next page, not just when
you select a option in the dropdown box.
 
T

Tim Slattery

Rabel said:
I am new to asp and I am having a little trouble with the Request.form
option. What I want to do is I have a dropdown box.

<select name="selecter" class="text" id="selecter">
<option value="page1.htm" selected>Page 1</option>
<option value="page2.htm">Page 2</option>
<option value="page3.htm">Page 3</option>
</select>

and I want to use a button that then will take you to the page you
selected so I have been trying codes like this.

<a href="<%= Request.Form("selecter") %>" ><img src="submit.jpg"
width="45" height="18" border="0"></a>

Looks OK at a glance. In order to use Request.Form, your form has to
have been POSTed, you cannot use method="get" if you're going to use
that. If you want that link to be in the same page as the select
group, then you have to rethink what you're doing. ASP is a
server-side platform, and the <%= tag in the <a href= HTML tag won't
work unless the form has been submitted and you're building a new
page.

It can be done in the same page, but it's done using client-side
Javascript (use a handler for the onChange event in the select group).
That being the case, it's off-topic in this group.
 
M

Marc

I think you want to try javascript for that but...
<%
Response.Redirect(Request.Form("selecter"))
%>

I can't help myself:

<select name="selecter" class="text" id="selecter"
onchange="if(this.selectedIndex>0)document.location.href=this.options[this.­selectedIndex].value">
<option value="" selected>Select page</option>
<option value="page1.htm">Page 1</option>
<option value="page2.htm">Page 2</option>
<option value="page3.htm">Page 3</option>
</select>

Make sure the "onchange" bit until the ">" is on one line!- Hide quoted
text -

- Show quoted text -

Thanks Marc - but is there a way that I can still use a button then
just when you select from the box.

Thanks


sure, but remember... this isn't a javascript group.

<form name="frm">
<select name="selecter" class="text" id="selecter">
<option value="page1.htm">Page 1</option>
<option value="page2.htm">Page 2</option>
<option value="page3.htm">Page 3</option>
</select>
<input type="button" value="go there"
onclick="document.location.href=document.frm.selecter.options[document.frm.selecter.selectedIndex].value"
/>
</form>
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top