Populate Dynamic dropdown box

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

    Populate Dynamic dropdown box

    Hi,

    have form on asp page that recalls data from the recordset and populates all
    the fields except the dynamic dropdown box that doesn't, just shows default
    value. How do I make it populate based on the entry in the db?

    Regards
    Simon


    --
    Simon Gare
    The Gare Group Limited

    website: www.thegaregroup.co.uk
    website: www.privatehiresolutions.co.uk


  • Bob Barrows [MVP]

    #2
    Re: Populate Dynamic dropdown box

    Simon Gare wrote:
    Hi,
    >
    have form on asp page that recalls data from the recordset and
    populates all the fields except the dynamic dropdown box that
    doesn't, just shows default value. How do I make it populate based on
    the entry in the db?
    >
    As you write each option string to Response, compare the string you are
    writing as the option's value to the data in the recordset. If They are
    the same, write "selected" to response before closing the option's tag.
    Otherwise, don't write "selected".

    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.


    Comment

    • Simon Gare

      #3
      Re: Populate Dynamic dropdown box

      Thanks Bob,

      Got it

      <select name="Access_le vel" id="select2">
      <option value"">Select access level</option>
      <option value="1" <% response.write "selected"
      %>>Driver</option>
      <option value="2" <% response.write "selected" %>>Operator /
      Controller</option>
      <option value="3" <% response.write "selected"
      %>>Administrato r</option>
      </select>

      Worked perfectly trying too hard again I was Dim this and Dim that couldnt
      get my head around it.

      Simon

      ..
      "Bob Barrows [MVP]" <reb01501@NOyah oo.SPAMcomwrote in message
      news:OhPbG7eWHH A.192@TK2MSFTNG P04.phx.gbl...
      Simon Gare wrote:
      Hi,

      have form on asp page that recalls data from the recordset and
      populates all the fields except the dynamic dropdown box that
      doesn't, just shows default value. How do I make it populate based on
      the entry in the db?
      >
      As you write each option string to Response, compare the string you are
      writing as the option's value to the data in the recordset. If They are
      the same, write "selected" to response before closing the option's tag.
      Otherwise, don't write "selected".
      >
      --
      Microsoft MVP -- ASP/ASP.NET
      Please reply to the newsgroup. The email account listed in my From
      header is my spam trap, so I don't check it very often. You will get a
      quicker response by posting to the newsgroup.
      >
      >

      Comment

      • Evertjan.

        #4
        Re: Populate Dynamic dropdown box

        Simon Gare wrote on 26 feb 2007 in
        microsoft.publi c.inetserver.as p.general:
        <select name="Access_le vel" id="select2">
        <option value"">Select access level</option>
        <option value="1" <% response.write "selected"
        %>>Driver</option>
        <option value="2" <% response.write "selected"
        %>>Operator /
        Controller</option>
        <option value="3" <% response.write "selected"
        %>>Administrato r</option>
        </select>
        >
        I don't think this is very useful as it just places a selected in each
        option, so probably the top one will have an effect.


        <%
        s = ~numeric result from database~
        %>

        <select name="Access_le vel" id="select2">
        <option value="">
        Select access level</option>
        <option value="1" <% if s=1 then response.write "selected" %>>
        Driver</option>
        <option value="2" <% if s=2 then response.write "selected" %>>
        Operator / Controller</option>
        <option value="3" <% if s=3 then response.write "selected" %>>
        Administrator</option>
        </select>


        --
        Evertjan.
        The Netherlands.
        (Please change the x'es to dots in my emailaddress)

        Comment

        • Bob Barrows [MVP]

          #5
          Re: Populate Dynamic dropdown box

          Simon Gare wrote:
          Thanks Bob,
          >
          Got it
          >
          <select name="Access_le vel" id="select2">
          <option value"">Select access level</option>
          <option value="1" <% response.write "selected"
          %>>Driver</option>
          <option value="2" <% response.write "selected"
          %>>Operator / Controller</option>
          <option value="3" <% response.write "selected"
          %>>Administrato r</option>
          </select>
          >
          Worked perfectly trying too hard again I was Dim this and Dim that
          couldnt get my head around it.
          >
          Simon
          >
          That works?? If you say so ...
          --
          Microsoft MVP -- ASP/ASP.NET
          Please reply to the newsgroup. The email account listed in my From
          header is my spam trap, so I don't check it very often. You will get a
          quicker response by posting to the newsgroup.


          Comment

          • Simon Gare

            #6
            Re: Populate Dynamic dropdown box

            Bob,

            have a problem, the way I did it hasn't worked should I be doing something
            like,

            <% if ACCESS_LEVEL(0) = true then response.write "selected" %>

            ??

            Simon


            "Simon Gare" <simon@simongar e.comwrote in message
            news:%23pSWcAfW HHA.4964@TK2MSF TNGP06.phx.gbl. ..
            Thanks Bob,
            >
            Got it
            >
            <select name="Access_le vel" id="select2">
            <option value"">Select access level</option>
            <option value="1" <% response.write "selected"
            %>>Driver</option>
            <option value="2" <% response.write "selected" %>>Operator /
            Controller</option>
            <option value="3" <% response.write "selected"
            %>>Administrato r</option>
            </select>
            >
            Worked perfectly trying too hard again I was Dim this and Dim that couldnt
            get my head around it.
            >
            Simon
            >
            .
            "Bob Barrows [MVP]" <reb01501@NOyah oo.SPAMcomwrote in message
            news:OhPbG7eWHH A.192@TK2MSFTNG P04.phx.gbl...
            Simon Gare wrote:
            Hi,
            >
            have form on asp page that recalls data from the recordset and
            populates all the fields except the dynamic dropdown box that
            doesn't, just shows default value. How do I make it populate based on
            the entry in the db?
            >
            As you write each option string to Response, compare the string you are
            writing as the option's value to the data in the recordset. If They are
            the same, write "selected" to response before closing the option's tag.
            Otherwise, don't write "selected".

            --
            Microsoft MVP -- ASP/ASP.NET
            Please reply to the newsgroup. The email account listed in my From
            header is my spam trap, so I don't check it very often. You will get a
            quicker response by posting to the newsgroup.
            >
            >

            Comment

            • Bob Barrows [MVP]

              #7
              Re: Populate Dynamic dropdown box

              Simon Gare wrote:
              Bob,
              >
              have a problem, the way I did it hasn't worked should I be doing
              something like,
              >
              <% if ACCESS_LEVEL(0) = true then response.write "selected" %>
              >
              ??
              >
              Yes, that's more like it. Have you tried it? Does it work? If not, write
              the value of ACCESS_LEVEL(0) to Response and show us what it is.
              --
              Microsoft MVP -- ASP/ASP.NET
              Please reply to the newsgroup. The email account listed in my From
              header is my spam trap, so I don't check it very often. You will get a
              quicker response by posting to the newsgroup.


              Comment

              • Simon Gare

                #8
                Re: Populate Dynamic dropdown box

                it did Bob thanks

                <option value="00:10" <% if (AirportStation .Fields.Item("L eadTime").Value ) =
                ("00:10:00") then response.write "selected" %>>10 Mins</option>

                Regards
                Simon

                "Bob Barrows [MVP]" <reb01501@NOyah oo.SPAMcomwrote in message
                news:eBJf8bfWHH A.996@TK2MSFTNG P02.phx.gbl...
                Simon Gare wrote:
                Bob,

                have a problem, the way I did it hasn't worked should I be doing
                something like,

                <% if ACCESS_LEVEL(0) = true then response.write "selected" %>

                ??
                Yes, that's more like it. Have you tried it? Does it work? If not, write
                the value of ACCESS_LEVEL(0) to Response and show us what it is.
                --
                Microsoft MVP -- ASP/ASP.NET
                Please reply to the newsgroup. The email account listed in my From
                header is my spam trap, so I don't check it very often. You will get a
                quicker response by posting to the newsgroup.
                >
                >

                Comment

                Working...