Writing a listbox value to an html link concatination

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Crystal

    Writing a listbox value to an html link concatination

    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(obj Name, 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

    #2
    Re: Writing a listbox value to an html link concatination

    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("l st_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" <cowings@vt.edu > wrote in message
    news:bb98286a.0 307080601.2d5e2 e9a@posting.goo gle.com...[color=blue]
    > 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(obj Name, 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 :)[/color]


    Comment

    • Crystal

      #3
      Re: Writing a listbox value to an html link concatination

      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("tx tName", "")%>>

      In a separate "scripts" page, the method then calls the "RequestInf o()
      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(obj Name, 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.

      Comment

      • Crystal

        #4
        Re: Writing a listbox value to an html link concatination

        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
        cowings@vt.edu, I'll be happy to send it to you that way, it's just
        way to much code to put in a forum.

        Crystal

        Comment

        • joshreno
          New Member
          • Jun 2006
          • 1

          #5
          Need list box action help..:(

          Originally posted by SPA
          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("l st_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" <cowings@vt.edu > wrote in message
          news:bb98286a.0 307080601.2d5e2 e9a@posting.goo gle.com...[color=blue]
          > 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(obj Name, 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 :)[/color]

          I have a list box loaded with a submit button but once the user selects something in the list box and clicks submit I would like a pdf to pop up of the option they chose. My list box seems fine and the submit button brings me to a page that I perform the If Statements in hopes of pulling the right PDF so I'll disregard that part of the code but maybe my if statements don't have the right syntax? here is a portion of that code. But it only brings up the Agoura_R3_B.pdf no matter what the user chose from the list box. A

          <html>
          <head>
          <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
          <title>Untitl ed Document</title>
          </head>
          <if option value="one">
          <FORM ACTION="\\cafrl oparesxt21\PDF_ Maps\Agoura_R3_ B.pdf">
          </if>

          <else option value="two">
          <FORM ACTION="\\cafrl oparesxt21\PDF_ Maps\Alhambra_E X.pdf">
          </else>
          <endif>
          </endif>
          <INPUT TYPE=SUBMIT>
          </FORM>
          <body>
          </body>
          </html>

          Comment

          Working...