Writing a listbox value to an html link concatination

Discussion in 'ASP General' started by Crystal, Jul 8, 2003.

  1. Crystal

    Crystal Guest

    Ok, I know this sounds weird, but it's really bugging me. I have a
    few list boxes on my form (basic pick a month, year, state stuff) and
    you can only choose one value. I need to be able to run a script to
    pick out those boxes and request the value and then response.write the
    value to a URL that I am creating. The script actually sends an email
    to me that contains a link to the form that the user filled in and
    populates the form with their information. Here is what I have so
    far, only the first and last cases work, I still can't figure out how
    to get it to work for "sel" (listboxes) and I also need to make it
    work for a text area:

    <%
    sub RequestInfo(objName, btnVal)
    Select Case left(objName,3)
    Case "rad", "chk"
    if Request(objName)=btnVal then
    Response.Write("checked")
    end if
    Case "sel"
    if Request(objName)=btnVal then
    Response.Write("selected")
    end if
    Case "txt"
    Response.Write "Value='" & Request(objName) & "'"
    End Select
    end sub
    %>

    Any help would be GREATLY appreciated! I just need it to write the
    selected value, don't worry about where it's coming from or where it's
    going, that all works fine :)
     
    Crystal, Jul 8, 2003
    #1
    1. Advertising

  2. Crystal

    SPA Guest

    Hi

    First of all, need to know how u populate your listbox control. It should be
    like:

    <select name="lst_Date">
    <option value="1">1</option>
    <option value="2">2</option>
    </select>

    If the value attribute has a value, then you could use
    Request.Form("lst_Date") in the form you are posting your page to.

    If you are not posting, then you should use the options[selectedIndex].value
    property of the listbox in Javascript. You can retrieve this and use it in
    your hyperlink.

    Syntax:
    document.<form name>.<listbox name>.options[selectedIndex].value

    Hope this is what you want.


    "Crystal" <> wrote in message
    news:...
    > Ok, I know this sounds weird, but it's really bugging me. I have a
    > few list boxes on my form (basic pick a month, year, state stuff) and
    > you can only choose one value. I need to be able to run a script to
    > pick out those boxes and request the value and then response.write the
    > value to a URL that I am creating. The script actually sends an email
    > to me that contains a link to the form that the user filled in and
    > populates the form with their information. Here is what I have so
    > far, only the first and last cases work, I still can't figure out how
    > to get it to work for "sel" (listboxes) and I also need to make it
    > work for a text area:
    >
    > <%
    > sub RequestInfo(objName, btnVal)
    > Select Case left(objName,3)
    > Case "rad", "chk"
    > if Request(objName)=btnVal then
    > Response.Write("checked")
    > end if
    > Case "sel"
    > if Request(objName)=btnVal then
    > Response.Write("selected")
    > end if
    > Case "txt"
    > Response.Write "Value='" & Request(objName) & "'"
    > End Select
    > end sub
    > %>
    >
    > Any help would be GREATLY appreciated! I just need it to write the
    > selected value, don't worry about where it's coming from or where it's
    > going, that all works fine :)
     
    SPA, Jul 8, 2003
    #2
    1. Advertising

  3. Crystal

    Crystal Guest

    Yeah, I have a plain static list box for selecting a state, simple
    enough and it's set up normally and hard coded. However, the way my
    code works is that I need to be able to capture the value that was
    selected and then pass that value to another function. This is how a
    text box works: Within the page with the form, each of the input
    forms looks something like this, with the tag on the end.

    <input name="txtName" type="text" <%Call RequestInfo("txtName", "")%>>

    In a separate "scripts" page, the method then calls the "RequestInfo()
    from the form tags. On submit, the scripts page is run and runs
    through all of the tags in the form, checking them against each case
    and the "btnVal" is then written to the URL, not posted:

    <%
    sub RequestInfo(objName, btnVal)
    Select Case left(objName,3)
    Case "rad", "chk"
    if Request(objName)=btnVal then
    Response.Write("checked")
    end if
    Case "sel"
    if Request(objName)=btnVal then
    Response.Write("selected")
    end if
    Case "txt"
    Response.Write "Value='" & Request(objName) & "'"
    End Select
    end sub
    %>


    My problem is that I am not quite sure how to get the <%Call
    RequestInfo....> to pull out the actual VALUE of what was selected in
    the listbox and I really don't want to have to hardcode each of the
    listboxes in that scripts page. Any ideas on how to dynamically
    capture that value?

    I know this is rather confusing, I have confused myself, but any help
    would be greatly appreciated.
     
    Crystal, Jul 9, 2003
    #3
  4. Crystal

    Crystal Guest

    I got it! I had a friend help me with it and it takes a lot of code
    to do it. But it's done, if anyone wants the code, email me at
    , I'll be happy to send it to you that way, it's just
    way to much code to put in a forum.

    Crystal
     
    Crystal, Jul 9, 2003
    #4
    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. Jakob Simon-Gaarde

    Preprocessor concatination of defines

    Jakob Simon-Gaarde, Jul 1, 2004, in forum: C++
    Replies:
    4
    Views:
    450
    Jack Klein
    Jul 2, 2004
  2. JChG
    Replies:
    1
    Views:
    249
    Steven D'Aprano
    Apr 19, 2010
  3. Noah Roberts
    Replies:
    5
    Views:
    781
    James Kanze
    Jan 12, 2011
  4. Rajika Somasiri

    String concatination

    Rajika Somasiri, Feb 9, 2004, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    147
    Tom Kiefer
    Feb 9, 2004
  5. Rajika Somasiri

    String concatination

    Rajika Somasiri, Feb 9, 2004, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    117
    Anusha Nanayakkara
    Feb 23, 2004
Loading...

Share This Page