Default value for combo box

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

    Default value for combo box

    How do I make a value the default value for a combo box in ASP 3.0?
    What I have below does NOT work, yet I've seen it in HTML file
    examples before (and works if I put it in a HTML file by itself, but
    not if I use it in a ASP 3.0 app.


    <select name="cboCompan y" style="text-align:right; font-size:8pt">
    <option value="08">08</option>
    <option value="09" selected="true" >09</option>
    <option value="33">33</option>
    <option value="18">18</option>
    <option value="17">17</option>
    </select>

  • Mike Brind

    #2
    Re: Default value for combo box


    "Doogie" <dnlwhite@dtgne t.comwrote in message
    news:1172274610 .316351.140100@ s48g2000cws.goo glegroups.com.. .
    How do I make a value the default value for a combo box in ASP 3.0?
    What I have below does NOT work, yet I've seen it in HTML file
    examples before (and works if I put it in a HTML file by itself, but
    not if I use it in a ASP 3.0 app.
    >
    >
    <select name="cboCompan y" style="text-align:right; font-size:8pt">
    <option value="08">08</option>
    <option value="09" selected="true" >09</option>
    <option value="33">33</option>
    <option value="18">18</option>
    <option value="17">17</option>
    </select>
    >
    While the above is not valid html, it should work in most browsers, because
    they appear to ignore what comes after "selected"

    Valid in html 4.01 and below: <option value="09" selected>09</option>
    Valid in xhtml: <option value="09" selected="selec ted">09</option>

    What you tried should also work in most browsers in an ASP app, because all
    asp does is render html. ASP is therefore not an issue.

    --
    Mike Brind


    Comment

    • Doogie

      #3
      Re: Default value for combo box

      While the above is not valid html, it should work in most browsers, because
      they appear to ignore what comes after "selected"
      What is invalid about it? I want to make it valid so if it's invalid
      please show me where.
      Valid in html 4.01 and below: <option value="09" selected>09</option>
      Valid in xhtml: <option value="09" selected="selec ted">09</option>
      Neither of these work. I can create this combo box in a simple html
      page and it works fine. But if I put it in an ASP 3.0 page, option 09
      is not the default one. Option 08 (the first one) is. Is there some
      other way - other than putting 09 first?

      Comment

      • Mark J. McGinty

        #4
        Re: Default value for combo box


        "Doogie" <dnlwhite@dtgne t.comwrote in message
        news:1172363420 .051060.146300@ 8g2000cwh.googl egroups.com...
        >While the above is not valid html, it should work in most browsers,
        >because
        >they appear to ignore what comes after "selected"
        >
        What is invalid about it? I want to make it valid so if it's invalid
        please show me where.
        >
        >Valid in html 4.01 and below: <option value="09" selected>09</option>
        >Valid in xhtml: <option value="09" selected="selec ted">09</option>
        >
        Neither of these work. I can create this combo box in a simple html
        page and it works fine. But if I put it in an ASP 3.0 page, option 09
        is not the default one. Option 08 (the first one) is. Is there some
        other way - other than putting 09 first?
        >
        Did you view the HTML source as generated by your ASP script? I suspect it
        is not generating exactly as you expect, because the browser doesn't care if
        the markup is static or dynamic, as long as its correct.


        -Mark


        Comment

        • Doogie

          #5
          Re: Default value for combo box

          Did you view the HTML source as generated by your ASP script? I suspect it
          is not generating exactly as you expect, because the browser doesn't care if
          the markup is static or dynamic, as long as its correct.
          Bear with me, I'm a little new to the web dev world. But if you mean
          did I do a "View source" on my asp page, I did and the HTML is as
          listed above (and below). This is a brand new control on this page,
          so there is no other code attached to it yet so I can't figure out why
          it won't default to 09 like I'm being told it should.

          The only thing else I can think of about this is that this combo box
          is being added to a grid that is defined with XSL. The html below is
          not part of the XSL, it's part of the HTML of the ASP page though. I
          tried to add this code to that XSL too and it didn't change my
          results.

          <select name="cboCompan y" style="text-align:right; font-size:8pt">
          <option value="08">08</option>
          <option value="09" selected="true" >09</option>
          <option value="33">33</option>
          <option value="18">18</option>
          <option value="17">17</option>
          </select>

          Comment

          • Mike Brind

            #6
            Re: Default value for combo box


            "Doogie" <dnlwhite@dtgne t.comwrote in message
            news:1172363420 .051060.146300@ 8g2000cwh.googl egroups.com...
            >While the above is not valid html, it should work in most browsers,
            >because
            >they appear to ignore what comes after "selected"
            >
            What is invalid about it? I want to make it valid so if it's invalid
            please show me where.
            The selected attribute in html 4.01 and below stands on its own In xhtml it
            has to have the attribute and its value, hence selected="selec ted".
            selected="true" does not exist in html or xhtml.
            >
            >Valid in html 4.01 and below: <option value="09" selected>09</option>
            >Valid in xhtml: <option value="09" selected="selec ted">09</option>
            >
            Neither of these work. I can create this combo box in a simple html
            page and it works fine. But if I put it in an ASP 3.0 page, option 09
            is not the default one. Option 08 (the first one) is. Is there some
            other way - other than putting 09 first?
            >
            They both work in my tests, as they should. Why they don't for you is a
            mystery. Please post the resulting source code from your page, and the
            relevant lines of ASP that you use to generate the Select list html.

            Incidentally, there is no such thing as a "combo box" in asp or html. ASP
            is a technology that renders html on request according to the instructions
            you give it in your code. The resulting html is then rendered by a browser
            as best it can. Stricly speaking, this is not an ASP problem, it's an html
            one.

            --
            Mike Brind


            Comment

            • Dave Anderson

              #7
              Re: Default value for combo box

              "Doogie" wrote:
              But if you mean did I do a "View source" on my asp page, I
              did and the HTML is as listed above (and below).
              >
              <select name="cboCompan y" style="text-align:right; font-size:8pt">
              <option value="08">08</option>
              <option value="09" selected="true" >09</option>
              <option value="33">33</option>
              <option value="18">18</option>
              <option value="17">17</option>
              </select>
              Then you know that you are generating invalid HTML. Fix your code so it
              assigns the selected attribute the value "selected", not "true".




              --
              Dave Anderson

              Unsolicited commercial email will be read at a cost of $500 per message. Use
              of this email address implies consent to these terms.

              Comment

              • Doogie

                #8
                Re: Default value for combo box

                I switched it to "selected ="selected"" and that still does not work.
                The "View Source" shows it as "selected="sele cted"" but the first
                option - Company 08 - is the one that shows as the default. I've
                tried it with just "selected" and that does not work either.

                Here is the entire HTML for this one page. I'm not sure how much help
                it will be because the app is many more pages than this and this
                particular grid is loaded with some java script according to an xsl
                file. But it shows that I clearly have it set the way I'm describing,
                but it is not showing the default the way I need it to. Like I
                mentioned, the html entry that I'm creating (cbocompany) is entirely
                brand new, so there shouldn't be any code prohibiting it from using
                the selected attribute as intended.


                <HTML>
                <HEAD>
                <title>Create Adhoc Invoice</title>
                <link REL="STYLESHEET " type="text/css" HREF="../CSS/CSXLines.css">
                <script language="javas cript" src="../includes/ReloadFooter.as p"></
                script>
                </HEAD>
                <BODY onfocus=closePo pUp() onload="ReloadF ooter('Adhoc Invoice -
                Create');" onkeypress="if( window.event.ke yCode==13)
                {btnDisplay.cli ck()}">
                <table cellspacing=1 cellpadding=0 border="0" width=610>
                <tr>
                <td width=250>
                <fieldset>
                <legend title="Search Criteria" style="font-size:8pt">Searc h
                Criteria</legend>
                <table width=100% border=0>
                <tr>
                <td class="small" align=right>Ven dor:</td>
                <td><span id=spnVendorSca cs></span></td>
                </tr>
                <tr>
                <td class="small" align=right>Ven dorTypes:</td>
                <td><span id=spnVendorTyp es></span></td>
                </tr>
                <tr>
                <td class="small" align=right>Inv oice Number:</td>
                <td><input type=text id=txtInvoiceNu mber style="font-size:8pt"
                maxlength=20 onkeypress="toU pper()"></td>
                </tr>
                </table>
                </fieldset>
                </td>
                <td width=20%>
                <table>
                <tr>
                <td><input type=button name=btnDisplay value=Display style="width:
                80px; font-size:8pt" onclick="GetAdh ocInvoices()" id="Button1"></td>
                </tr>
                <tr>
                <td><input type=button name=btnClear value=Clear style="width:
                80px; font-size:8pt" onclick="ClearA ll()"></td>
                </tr>
                <tr>
                <td><input type=button name=btnAddVend or value="Add Vendor"
                style="width:80 px; font-size:8pt" onclick="AddVen dor()"></td>
                </tr>
                </table>
                </td>
                <td>
                <table height=90 align=right>
                <tr>
                <td><font face=verdana size=4><input type=button name=btnSave
                value="Save Changes" style="width:80 px; font-size:8pt;font-
                face:verdana;" onclick="CallSa veChanges()"></font></td>
                </tr>


                <tr>
                <td>
                <font face=verdana size=4><input type=button name=btnComplet e
                value=Complete style=width:80p x;font-size:8pt;font-face:verdana;
                onclick=CallCom plete()></font>
                </td>
                </tr>

                </table>
                </td>
                </tr>
                <tr>
                <td align=center colspan=3>
                <span id=spnTableDisp lay oncontextmenu=" AdhocRightClick (null);
                return false" STYLE="overflow :auto; width:610px; height:170px;
                position:relati ve; padding:0px; margin:0px; border-left:1px gray
                solid; border-right:1px gray solid; border-top:1px gray solid; border-
                bottom:1px gray solid"></span>
                </td>
                </tr>
                <tr>
                <td align=left>
                <span id=spnAdhocDeta ils
                oncontextmenu=" AdhocDetailRigh tClick(null); return false"
                STYLE="overflow :auto; width:340px; height:185px; position:relati ve;
                padding:0px; margin:0px; border-left:1px gray solid; border-right:1px
                gray solid; border-top:1px gray solid; border-bottom:1px gray solid"></
                span>
                </td>
                <td align=right valign=top colspan=2>
                <table>
                <tr>
                <td class="small" align=right>
                Total Amount
                </td>
                </tr>
                <tr>
                <td>
                <input type=text name=txtTotalAm ount style="width:12 0px; font-
                size:8pt; background-color:silver; text-align:right" readonly>
                </td>
                </tr>
                <tr>
                <td class="small" align=right>
                Total Pay Amount
                </td>
                </tr>
                <tr>
                <td>
                <input type=text name=txtTotalPa yAmount style="width:12 0px; font-
                size:8pt; background-color:silver; text-align:right" readonly>
                </td>
                </tr>
                </table>
                </td>
                </tr>
                <tr>
                <td align=center><s pan id=clientCallXM L></span></td>
                </tr>
                <tr>
                <td align=center><s pan id=returnXML></span></td>
                </tr>
                </table>

                <span id=spnHidden style="visibili ty:hidden; overflow:auto; width:1px;
                height:1px;">
                <table><tbody id=spareDetailT able>
                <tr align="center" style="font-family:verdana, arial; font-size:8pt;
                background-color:white" onclick="onRowC lick_singleSel( this,
                'ADHOC_DETAIL') " oncontextmenu=" AdhocDetailRigh tClick(this); return
                false">
                <td>
                <input type="hidden" name="hdn_ItemI D">
                <input type="text" name="txt_ItemD S" size="20" readonly=""
                style="font-size:8pt">
                </td>
                <td align="right">
                <input type="text" name="txt_ItemQ T"
                onkeypress="fil terNonNumeric() " maxlength="4" size="6" style="text-
                align:right; font-size:8pt" >
                </td>
                <td align="right">
                <input type="text" name="txt_ItemA M" value="$0.00"
                onblur="checkCu rrency(this); recalcTotal()" maxlength="10" size="12"
                style="text-align:right; font-size:8pt">
                </td>
                </tr>
                <tr align="center" style="font-family:verdana, arial; font-size:8pt;
                background-color:white; height:30">
                <td></td>
                <td class="small" align="right">T otal Amount:</td>
                <td class="small" align="right">$ 0.00</td>
                </tr>
                </tbody></table>
                <table><tbody id=spareInvoice Table>
                <tr align="center" style="font-family:verdana, arial; font-size:8pt;
                background-color:white" onclick="AdhocI nvoiceSelected( this)"
                oncontextmenu=" AdhocRightClick (this); return false">
                <td>
                <input type="hidden" name="hdn_MATCH _FL">
                <input type="hidden" name="hdn_total Amount" value="EMPTY">
                <input type="hidden" name="hdn_statu s" value="insert">
                <input type="hidden" name="hdn_detai lStatus" value="clean">
                <input type="hidden" name="hdn_SCAC_ CD">
                <input type="hidden" name="hdn_compa ny_id" value="">
                <input type="text" name="txt_SCAC_ AN" readonly="" size="10"
                style="backgrou nd-color:silver; font-size:8pt">
                <input type="hidden" name="hdn_Appr_ id" value="EMPTY">
                </td>
                <td>
                <input type="text" name="txt_INVOI CE_NUMBER_AN" size="10"
                maxlength="20" style="font-size:8pt"
                onchange="check InvoiceNumber(t his)" onblur="if(!
                this.readOnly)c heckInvoiceNumb er(this)" onkeypress="toU pper()">
                </td>
                <td>
                <input type="text" name="txt_VENDO R_TYPE_AN" readonly="" size="5"
                style="backgrou nd-color:silver;te xt-align:center; font-size:8pt">
                </td>
                <td>
                <input type="text" name="txt_ACCOU NTING_CD" readonly="" size="10"
                style="backgrou nd-color:silver; font-size:8pt">
                </td>
                <td>
                <input type="text" name="txt_INVOI CE_DT" onBlur="checkda te(this)"
                size="11" maxlength="11" style="font-size:8pt">
                </td>
                <td>
                <input type="text" name="txt_ACCRU AL_DT" onBlur="checkda te(this)"
                size="11" maxlength="11" style="font-size:8pt">
                </td>
                <td>
                <input type="text" name="txt_BEGIN _BILLING_DT"
                onBlur="checkda te(this)" size="11" maxlength="11" style="font-size:
                8pt">
                </td>
                <td>
                <input type="text" name="txt_END_B ILLING_DT"
                onBlur="checkda te(this)" size="11" maxlength="11" style="font-size:
                8pt">
                </td>
                <td>
                <input type="text" name="txt_AP_SE NT_DT" onBlur="checkda te(this)"
                size="11" maxlength="11" readonly="" style="backgrou nd-color:silver;
                font-size:8pt">
                </td>
                <td>
                <input type="text" name="txt_AP_RE CEIVED_DT"
                onBlur="checkda te(this)" size="11" maxlength="11" readonly=""
                style="backgrou nd-color:silver; font-size:8pt">
                </td>
                <td>
                <input type="text" name="txt_IP10_ AN" size="5" maxlength="3"
                style="font-size:8pt">
                </td>
                <!--h0448-->
                <td>
                <!--<input type="text" name="txt_SERVI CE_SN"
                onkeypress="fil terNonNumeric() " size="5" maxlength="3" style="text-
                align:right; font-size:8pt">-->
                <select name="txt_SERVI CE_SN" style="text-align:right; font-size:
                8pt">
                <option value="23">23</option>
                <option value="60">60</option>
                <option value="14">14</option>
                <option value="18">18</option>
                <option value="17">17</option>
                </select>
                </td>
                <!--h0448-->
                <td>
                <select name="cboCompan y" style="text-align:right; font-size:8pt">
                <option value="08">08</option>
                <option value="09" selected="selec ted">09</option>
                <option value="33">33</option>
                <option value="18">18</option>
                <option value="17">17</option>
                </select>
                </td>
                <td>
                <input type="checkbox" name="chkBxTaxa ble"
                onclick="taxabl eClicked(this)" >
                </td>
                <td>
                <a class="small" href="javascrip t:selectTaxName ()"
                id="a_TAX_NAME_ DS">NULL</a>
                <input type="hidden" name="txt_TAX_I D">
                </td>
                <td>
                <input type="text" name="txt_COMME NT_DS" size="15" maxlength="132"
                style="font-size:8pt">
                </td>
                </tr>
                </tbody></table>
                </span>
                <script>

                </BODY>
                </HTML>



                Comment

                • Mike Brind

                  #9
                  Re: Default value for combo box


                  "Doogie" <dnlwhite@dtgne t.comwrote in message
                  news:1172439267 .230980.83040@a 75g2000cwd.goog legroups.com...
                  >I switched it to "selected ="selected"" and that still does not work.
                  The "View Source" shows it as "selected="sele cted"" but the first
                  option - Company 08 - is the one that shows as the default. I've
                  tried it with just "selected" and that does not work either.
                  >
                  Here is the entire HTML for this one page. I'm not sure how much help
                  it will be because the app is many more pages than this and this
                  particular grid is loaded with some java script according to an xsl
                  file. But it shows that I clearly have it set the way I'm describing,
                  but it is not showing the default the way I need it to. Like I
                  mentioned, the html entry that I'm creating (cbocompany) is entirely
                  brand new, so there shouldn't be any code prohibiting it from using
                  the selected attribute as intended.
                  >
                  The html is useless without the js files. It doesn't show anything on its
                  own. One thing though, when I loaded it into Dreamweaver, the codeview
                  through a fit. The reason for that is that your html is so full of errors
                  that it couldn't cope, and colour-coded everything wrong. This is
                  definitely NOT an asp problem. Run your page through an html validator and
                  fix all the errors. That will, IMO, fix your problem.

                  If you need help with that, try an html group.

                  --
                  Mike Brind


                  Comment

                  • Doogie

                    #10
                    Re: Default value for combo box

                    I appreciate your help (everyones). But I'm not sure how much time I
                    am going to be allowed to do anything other than try to get the combo
                    box to default as I explained above. I'm new and this app is an old
                    app and it's ASP 3.0 which means its old technology too. My
                    experience before coming here is more in back-end development and so I
                    may have to ask someone else to try to tackle why what should be a
                    simple change isn't working because I just don't get it. Thanks
                    though again. Doug


                    Comment

                    • Mike Brind

                      #11
                      Re: Default value for combo box


                      "Doogie" <dnlwhite@dtgne t.comwrote in message
                      news:1172459300 .604249.276160@ h3g2000cwc.goog legroups.com...
                      >I appreciate your help (everyones). But I'm not sure how much time I
                      am going to be allowed to do anything other than try to get the combo
                      box to default as I explained above. I'm new and this app is an old
                      app and it's ASP 3.0 which means its old technology too. My
                      experience before coming here is more in back-end development and so I
                      may have to ask someone else to try to tackle why what should be a
                      simple change isn't working because I just don't get it. Thanks
                      though again. Doug
                      >
                      As I said, it's simple: for html to render correctly in a browser, it has to
                      be correct. The resulting html in your page is not. I suspect that the
                      errors further up the page are what is preventing the select list from
                      showing up as you expect. If you take that part of the html out and paste
                      it on its own in a page, it works. If you put the select list much firther
                      up your page, it will probably work, because it won't be "infected" by
                      preceding bad html. Fix the errors, then it will work. That's all anyone
                      here can suggest. Ignore the fact that you are using ASP. That's a red
                      herring.

                      --
                      Mike Brind


                      Comment

                      • Mark J. McGinty

                        #12
                        Re: Default value for combo box


                        "Doogie" <dnlwhite@dtgne t.comwrote in message
                        news:1172459300 .604249.276160@ h3g2000cwc.goog legroups.com...
                        >I appreciate your help (everyones). But I'm not sure how much time I
                        am going to be allowed to do anything other than try to get the combo
                        box to default as I explained above. I'm new and this app is an old
                        app and it's ASP 3.0 which means its old technology too. My
                        experience before coming here is more in back-end development and so I
                        may have to ask someone else to try to tackle why what should be a
                        simple change isn't working because I just don't get it. Thanks
                        though again. Doug
                        You are surely free to do that... main drawback to that plan is that you
                        still seem to believe ASP has something to do with this problem. Since
                        that, in fact, is not the case, you've saddled yourself with a distinct
                        disadvantage. It's very difficult (if not impossible) to make any progress
                        while persistently asking the wrong questions.

                        Typically, I avoid definitive statements like the one above... I've been
                        programming professionally going on 20 years, I worked on the DoD contract
                        project that delivered the very first Windows App created for the US Army...
                        over the years I've witnessed any number of things that were amazingly
                        anomalous, entirely inexplicable and/or *highly* improbable by definition.
                        Experience leaves me hesitant to say that anything in IT specifically could
                        or couldn't be, especially sight unseen... usually... anyway...

                        Out of curiosity I copied the html source you posted to a local html file.
                        There was an unclosed script tag near the bottom, but after I fixed that,
                        the page rendered. I fully expected to see '09' in that SELECT element, but
                        to my surprise, I didn't see the SELECT element at all. I knew it was in
                        the source, though, so I used a tool I wrote (www.pagespy.com) to look for
                        it.

                        As it turns out, the SELECT element is contained by a SPAN that is hidden in
                        two ways. (style.visibili ty = 'hidden', and style.width/style.height both
                        set to 1px.) I used pagespy's script context to change those styles/reveal
                        the element in question -- predictably, the initial value of the SELECT
                        element was '09'. Surprised me not at all.

                        The exercise would be pointless, but I can guarantee you that if I renamed
                        this file .asp and copied it to my local web root, it would render the same
                        '09', just as we all know it's supposed to. Test concluded.


                        Ok, so exactly what, if anything, does all this prove? (And, as long as
                        we're asking rhetorical questions, how could it possibly justify all the
                        rambling-on you see above?) Very astute of you to ask, I'll tell you:

                        1. You aren't able to see the SELECT element in question immediately after
                        the page renders -- if you were you would've seen that the selected
                        attribute does/did work.
                        2. By the time you *are* able to *actually* see it, some client-side script
                        has already been executed in response some UI interaction.
                        3. Said client-side script clearly concerns itself with the SELECT in
                        question (and its other initially-hidden SPAN-dweller siblings.)
                        4. You purposely omitted from your post some client script that was present
                        in the source dump -- what else explains the unclosed SCRIPT tag (presence
                        of which prevents the page from rendering in the least tiny way)? (I won't
                        even ask why.)
                        5. Without all of the page's client script, impossible for me to quote-back
                        the line of it that's responsible, but regardless, there is NOT A DOUBT in
                        my mind that's what is happening...
                        6. Client script -- not ASP -- is changing the selected option, before it
                        lets you see it.


                        If you still have any doubts, disable Active Script in IE security, change
                        the code so that can see the element you've been on about for days...
                        observe... and then post an accurate description of how this experience made
                        you feel.


                        Good Luck,
                        Mark




                        Comment

                        • Doogie

                          #13
                          Re: Default value for combo box

                          There was an unclosed script tag near the bottom, but after I fixed that, the page rendered.

                          I apologize about that, I did pull the javascript out of the code
                          because I am not all that sure how much I should be posting of this
                          code. It's not that it's overly secure or anything but I just wanted
                          to be careful and wasn't sure if there was anything in there that was
                          secure.
                          As it turns out, the SELECT element is contained by a SPAN that is hidden in two ways. (style.visibili ty = 'hidden', and style.width/style.height both set to 1px.) I >used pagespy's script context to change those styles/reveal the element in question -- predictably, the initial value of the SELECT element was '09'. Surprised me not >at all.
                          I did that too after you suggested it - thank you. But it doesn't
                          really solve my problem. See, the grid this select element is in is
                          hidden until the user tries to add a new invoice. At that point it
                          shows up (all of this I believe you touch on in your 6 points). If I
                          remove the hidden settings, then the grid shows up (and not even in
                          the right place). But I think you have at least pointed me down the
                          right path, where now I know where to work in order to get this to
                          work properly.

                          I agree now with everyone who has said from the beginning that this
                          isn't an ASP problem.
                          >and then post an accurate description of how this experience made you feel.
                          >From the beginning I've felt like I'm right out of college again where
                          nothing makes sense to me yet. :)

                          Again, thanks for the help.

                          Comment

                          Working...