load pull down menu on JSP page

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

    load pull down menu on JSP page

    I am new to Javascript and I am having problems with loading a pull
    down menu.

    I get this error:
    javax.servlet.S ervletException : No data found

    It will list the items just fine if I just list the items without
    using the select & option tags. I would like to know why I am getting
    an error with the following statement:

    <select size="1" name="org">
    <% while (rs.next()) { %>
    <option value="<%=rs.ge tString("ORG_CO DE")%>">
    <%=rs.getString ("ORG_CODE") %>
    </option>
    <% } %>
    </select>

    Thank you.
    -jptu
  • mscir

    #2
    Re: load pull down menu on JSP page

    jt wrote:
    [color=blue]
    > I am new to Javascript and I am having problems with loading a pull
    > down menu.
    >
    > I get this error:
    > javax.servlet.S ervletException : No data found
    >
    > It will list the items just fine if I just list the items without
    > using the select & option tags. I would like to know why I am getting
    > an error with the following statement:
    >
    > <select size="1" name="org">
    > <% while (rs.next()) { %>
    > <option value="<%=rs.ge tString("ORG_CO DE")%>">
    > <%=rs.getString ("ORG_CODE") %>
    > </option>
    > <% } %>
    > </select>[/color]

    Did you try:

    <option value="<%=rs.ge tString('ORG_CO DE')%>">

    Comment

    • phuong tu

      #3
      Re: load pull down menu on JSP page

      Yes, I've tried it and it didn't work.

      thanks,
      jptu



      *** Sent via Developersdex http://www.developersdex.com ***
      Don't just participate in USENET...get rewarded for it!

      Comment

      • mscir

        #4
        Re: load pull down menu on JSP page

        phuong tu wrote:[color=blue]
        > Yes, I've tried it and it didn't work.[/color]

        What's the url of the page, or post the relevant code here.

        Comment

        • Michael Winter

          #5
          Re: load pull down menu on JSP page

          On 7 Apr 2004 18:11:04 -0700, jt <judiphuongtu@y ahoo.com> wrote:
          [color=blue]
          > I am new to Javascript and I am having problems with loading a pull
          > down menu.[/color]

          OK...
          [color=blue]
          > I get this error:
          > javax.servlet.S ervletException : No data found
          >
          > It will list the items just fine if I just list the items without
          > using the select & option tags. I would like to know why I am getting
          > an error with the following statement:
          >
          > <select size="1" name="org">
          > <% while (rs.next()) { %>
          > <option value="<%=rs.ge tString("ORG_CO DE")%>">
          > <%=rs.getString ("ORG_CODE") %>
          > </option>
          > <% } %>
          > </select>[/color]

          ....but I don't see how this is related to JavaScript. You're problem is
          with JSP.

          You can find the JSP support forums at:

          <URL:http://forum.java.sun. com/forum.jsp?forum =45>

          Good luck,
          Mike

          --
          Michael Winter
          M.Winter@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)

          Comment

          • kaeli

            #6
            Re: load pull down menu on JSP page

            In article <6f38222f.04040 71711.306bc0b@p osting.google.c om>,
            judiphuongtu@ya hoo.com enlightened us with...[color=blue]
            > I am new to Javascript and I am having problems with loading a pull
            > down menu.
            >
            > I get this error:
            > javax.servlet.S ervletException : No data found[/color]

            Probably because your query isn't returning any data, but something
            expects it to.

            [color=blue]
            >
            > It will list the items just fine if I just list the items without
            > using the select & option tags. I would like to know why I am getting
            > an error with the following statement:
            >
            > <select size="1" name="org">
            > <% while (rs.next()) { %>
            > <option value="<%=rs.ge tString("ORG_CO DE")%>">
            > <%=rs.getString ("ORG_CODE") %>
            > </option>
            > <% } %>
            > </select>
            >[/color]

            You have no code here as to what to do if there is no rs.next() - that
            is, if the query returns no rows. If it returns no rows, you get an
            empty select element. That might be mucking up other code that assumes
            there is data in the select element.
            Add code that counts how many rows are returned, then check that and
            throw an error or something to handle 0 rows.


            --
            --
            ~kaeli~
            Dancing cheek-to-cheek is really a form of floor play.



            Comment

            • phuong tu

              #7
              Re: load pull down menu on JSP page

              Thanks for all your inputs. Sorry, I should have posted this under
              java. I found 2 tips to make it work.

              1. I changed my select statement from "select * ..." to "select ORG_CODE
              ..."
              2. I assigned the data pulled from recordset to a variable before
              inserting it to the pull down.

              here's the revised version:
              <select size="1" name="org">
              <%
              String org = null;
              while (rs.next())
              {
              org = rs.getString("O RG_CODE"); %>
              <option value="<%=org%> ">
              <%=org%>
              </option>
              <%
              } %>
              </select>




              *** Sent via Developersdex http://www.developersdex.com ***
              Don't just participate in USENET...get rewarded for it!

              Comment

              • kaeli

                #8
                Re: load pull down menu on JSP page

                In article <40759bed$0$193 $75868355@news. frii.net>,
                judiphuongtu@ya hoo.com enlightened us with...[color=blue]
                > Thanks for all your inputs. Sorry, I should have posted this under
                > java. I found 2 tips to make it work.
                >
                > 1. I changed my select statement from "select * ..." to "select ORG_CODE
                > .."
                > 2. I assigned the data pulled from recordset to a variable before
                > inserting it to the pull down.
                >[/color]

                You might also want to do something special in case the org code is
                null, if null values are allowed. Otherwise it just prints out the
                string "null", which might not be what you want.


                --
                --
                ~kaeli~
                The more ridiculous a belief system, the higher probability
                of its success.



                Comment

                Working...