Combo Value and Name

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

    Combo Value and Name

    If I click the "Update" button on my form below, I can retrieve the value of
    my combo by using code in the FORM RESULTS section below. Therefore, if I
    choose the "Inside" option in my combo, I would get "1" as the value of my
    combo box.

    Is there any way to retrieve the Name associated with the value? So not only
    retrieve the combo value of 1, but also retrieve the name "Inside" after
    submitting my form?



    FORM RESULTS *************** *******

    cboMachineArea= Request.Form("c boMachineArea")


    FORM CODE *************** *********

    <form name="DataForm" method=post action="form_te st.asp">

    <font face="Verdana,s ans-serif" size="2">Name</font><br>

    <input type="textbox" size=30 name="Full Name" value="My Test Name"><br>
    <font face="Verdana,s ans-serif" size="2">Area</font><br>
    <select name="cboArea" id="cboArea">
    <OPTION value="1" selected>Inside </option>
    <OPTION value="2">Outsi de</option>
    </select>

    <br>
    <input type=submit name="DataFormS ubmit" value="Update">
    </form>



  • Ray Costanzo [MVP]

    #2
    Re: Combo Value and Name

    No, browser don't post that data back to the server. Either look the text
    value back up from the same source you used to generate the dropdown box in
    the first page, or include the text value in the option value and parse it
    out.

    <select name="cboArea">
    <option value="1,Inside ">1</option>
    <option value="2,Outsid e">2</option>
    </select>


    <%

    Dim aParts
    aParts = Split(Request.F orm("cboArea"), ",")

    Response.Write "ID value = " & aParts(0) & "<hr>"
    Response.Write "Text value = " & aParts(1)

    %>

    Ray at work


    "Scott" <sbailey@milesl umber.comwrote in message
    news:%231T9t79x GHA.4092@TK2MSF TNGP04.phx.gbl. ..
    If I click the "Update" button on my form below, I can retrieve the value
    of my combo by using code in the FORM RESULTS section below. Therefore, if
    I choose the "Inside" option in my combo, I would get "1" as the value of
    my combo box.
    >
    Is there any way to retrieve the Name associated with the value? So not
    only retrieve the combo value of 1, but also retrieve the name "Inside"
    after submitting my form?
    >
    >
    >
    FORM RESULTS *************** *******
    >
    cboMachineArea= Request.Form("c boMachineArea")
    >
    >
    FORM CODE *************** *********
    >
    <form name="DataForm" method=post action="form_te st.asp">
    >
    <font face="Verdana,s ans-serif" size="2">Name</font><br>
    >
    <input type="textbox" size=30 name="Full Name" value="My Test Name"><br>
    <font face="Verdana,s ans-serif" size="2">Area</font><br>
    <select name="cboArea" id="cboArea">
    <OPTION value="1" selected>Inside </option>
    <OPTION value="2">Outsi de</option>
    </select>
    >
    <br>
    <input type=submit name="DataFormS ubmit" value="Update">
    </form>
    >
    >
    >

    Comment

    • Mike Brind

      #3
      Re: Combo Value and Name

      Or, if that really is the select group's options and ithey will never
      change, drop the value altogether. It doesn't seem to serve any
      purpose in this example:

      <select name="cboArea">
      <option>Insid e</option>
      <option>Outside </option>
      </select>

      Ray's suggestions are the best option (no pun intended) for lists that
      may change or ones that are generated dynamically.

      --
      Mike Brind

      Ray Costanzo [MVP] wrote:
      No, browser don't post that data back to the server. Either look the text
      value back up from the same source you used to generate the dropdown box in
      the first page, or include the text value in the option value and parse it
      out.
      >
      <select name="cboArea">
      <option value="1,Inside ">1</option>
      <option value="2,Outsid e">2</option>
      </select>
      >
      >
      <%
      >
      Dim aParts
      aParts = Split(Request.F orm("cboArea"), ",")
      >
      Response.Write "ID value = " & aParts(0) & "<hr>"
      Response.Write "Text value = " & aParts(1)
      >
      %>
      >
      Ray at work
      >
      >
      "Scott" <sbailey@milesl umber.comwrote in message
      news:%231T9t79x GHA.4092@TK2MSF TNGP04.phx.gbl. ..
      If I click the "Update" button on my form below, I can retrieve the value
      of my combo by using code in the FORM RESULTS section below. Therefore, if
      I choose the "Inside" option in my combo, I would get "1" as the value of
      my combo box.

      Is there any way to retrieve the Name associated with the value? So not
      only retrieve the combo value of 1, but also retrieve the name "Inside"
      after submitting my form?



      FORM RESULTS *************** *******

      cboMachineArea= Request.Form("c boMachineArea")


      FORM CODE *************** *********

      <form name="DataForm" method=post action="form_te st.asp">

      <font face="Verdana,s ans-serif" size="2">Name</font><br>

      <input type="textbox" size=30 name="Full Name" value="My Test Name"><br>
      <font face="Verdana,s ans-serif" size="2">Area</font><br>
      <select name="cboArea" id="cboArea">
      <OPTION value="1" selected>Inside </option>
      <OPTION value="2">Outsi de</option>
      </select>

      <br>
      <input type=submit name="DataFormS ubmit" value="Update">
      </form>

      Comment

      Working...