Easy question - Trouble with Request.Form

Discussion in 'ASP General' started by Rabel, Apr 4, 2007.

  1. Rabel

    Rabel Guest

    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
     
    Rabel, Apr 4, 2007
    #1
    1. Advertising

  2. Rabel

    Marc Guest

    "Rabel" <> wrote in message
    news:...
    >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"))
    %>
     
    Marc, Apr 4, 2007
    #2
    1. Advertising

  3. Rabel

    Marc Guest

    "Marc" <> wrote in message
    news:...
    > "Rabel" <> wrote in message
    > news:...
    >>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"))
    > %>
    >

    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!
     
    Marc, Apr 4, 2007
    #3
  4. Rabel

    Rabel Guest

    On Apr 4, 1:08 pm, "Marc" <> wrote:
    > "Marc" <> wrote in message
    >
    > news:...
    >
    >
    >
    > > "Rabel" <> wrote in message
    > >news:...
    > >>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"))
    > > %>

    >
    > 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
     
    Rabel, Apr 4, 2007
    #4
  5. Rabel

    Rabel Guest

    On Apr 4, 3:02 pm, "Jon Paal [MSMD]" <Jon nospam Paal @ everywhere dot
    com> wrote:
    > 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.
    >
    >
    >
    > "Rabel" <> wrote in messagenews:...
    > >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- Hide quoted text -

    >
    > - 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.
     
    Rabel, Apr 4, 2007
    #5
  6. Rabel

    Tim Slattery Guest

    "Rabel" <> wrote:

    >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.

    --
    Tim Slattery
    MS MVP(DTS)

    http://members.cox.net/slatteryt
     
    Tim Slattery, Apr 4, 2007
    #6
  7. Rabel

    Marc Guest

    "Rabel" <> wrote in message
    news:...
    On Apr 4, 1:08 pm, "Marc" <> wrote:
    > "Marc" <> wrote in message
    >
    > news:...
    >
    >
    >
    > > "Rabel" <> wrote in message
    > >news:...
    > >>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"))
    > > %>

    >
    > 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>
     
    Marc, Apr 4, 2007
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brian Birtle
    Replies:
    2
    Views:
    2,052
    John Saunders
    Oct 16, 2003
  2. Hazzard
    Replies:
    2
    Views:
    651
    Hazzard
    Apr 6, 2004
  3. Bruno Desthuilliers
    Replies:
    5
    Views:
    395
    Bruno Desthuilliers
    Aug 29, 2007
  4. Chris Shipley

    Trouble retrieving value with request.form

    Chris Shipley, Jan 12, 2004, in forum: ASP General
    Replies:
    1
    Views:
    161
    Aaron Bertrand [MVP]
    Jan 12, 2004
  5. Sean Dotson

    Trouble with Request.Form Plus Upload

    Sean Dotson, May 5, 2004, in forum: ASP General
    Replies:
    2
    Views:
    155
    Sean Dotson
    May 5, 2004
Loading...

Share This Page