Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6686849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:13:11+00:00 2026-05-26T05:13:11+00:00

I am working on a project using Spring. I am trying to fetch a

  • 0

I am working on a project using Spring. I am trying to fetch a set of data from the database and the value will be displayed on textboxes, but instead of giving me String, I keep encountered NaN (Not A Number). Here is part of the source code :

$( "#dialogFormSalesOrder" ).dialog({
                       autoOpen: false,
                       height: 300,
                       width: 600,
                       modal: true,
                       buttons: {
                          "Pick": function() {

                            //var bValid = true;
                            //allFields.removeClass( "ui-state-error" );

                            $(idSalesOrder).val($("#rdbSalesOrder:checked").val());


                        //window.location.replace("managedelivery.htm");
                           <% 

                               Connection connection = null;
                               String driverName = "com.mysql.jdbc.Driver";
                               Class.forName(driverName);
                               String serverName = "localhost:3306";
                               String mydatabase = "versedb";
                               String url = "jdbc:mysql://" + serverName +  "/" + mydatabase; // a JDBC url

                                String username = "root";
                                String password = "";
                                connection = DriverManager.getConnection(url, username,password);

                                Statement stmt = connection.createStatement();
                                ResultSet rs = stmt.executeQuery("Select idProduct, quantity from vrs_tsodetail where idSO='SO101'");

                                while(rs.next())

                                {%>



                                        $("#warehouse tbody" + "").append(
                                            "<tr>" +
                                            '<td><input id="idProduct" name="idProduct" value="' + <% String s = rs.getString(1).toString();  %> + '" /></td>' +
                                            '<td><input id="idQuantity" name="idQuantity" value="' + <%  s = rs.getString(2); %> + '" /></td>' +
                                            '<td><input id="idUnit" name="idUnit" value="cccccc" /></td>' + "</tr>"
                                        );

                                <%}%>




                            $( this ).dialog("close");
                        },
                        Cancel: function() {
                            $( this ).dialog( "close" );
                        }
                    },
                    close: function() {
                        //allFields.val( "" ).removeClass( "ui-state-error" );

                    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T05:13:11+00:00Added an answer on May 26, 2026 at 5:13 am

    Here’s the extract of relevance from your code:

    $("#warehouse tbody" + "").append(
        "<tr>" +
        '<td><input id="idProduct" name="idProduct" value="' + <% String s = rs.getString(1).toString();  %> + '" /></td>' +
        '<td><input id="idQuantity" name="idQuantity" value="' + <%  s = rs.getString(2); %> + '" /></td>' +
        '<td><input id="idUnit" name="idUnit" value="cccccc" /></td>' + "</tr>"
    );
    

    There are 2 problems here (there are actually more serious problems with this code in general, but they do not actually affect the functionality):

    1. You are not printing anything to the response.
    2. You’re expecting that Java and JavaScript runs in sync.

    To solve problem 1, you need to use <%= %> instead of assigning them to a String in a <% %> and then totally ignoring it.

    $("#warehouse tbody" + "").append(
        "<tr>" +
        '<td><input id="idProduct" name="idProduct" value="' + <%= rs.getString(1) %> + '" /></td>' +
        '<td><input id="idQuantity" name="idQuantity" value="' + <%= rs.getString(2) %> + '" /></td>' +
        '<td><input id="idUnit" name="idUnit" value="cccccc" /></td>' + "</tr>"
    );
    

    To solve problem 2, you need to remove those JavaScript string concatenations on Java/JSP-printed values. You should see Java/JSP as a HTML/JS code generator. Otherwise they will be treated as names of existing JavaScript variables. Assuming that 1st column returns "foo" and 2nd column returns "bar", this would only end up in the generated JS code like so (rightclick page in browser, do View Source to see it yourself):

    $("#warehouse tbody" + "").append(
        "<tr>" +
        '<td><input id="idProduct" name="idProduct" value="' + foo + '" /></td>' +
        '<td><input id="idQuantity" name="idQuantity" value="' + bar + '" /></td>' +
        '<td><input id="idUnit" name="idUnit" value="cccccc" /></td>' + "</tr>"
    );
    

    But you don’t have those variables definied anywhere in JS code, right? They’re undefined. You need to inline it in the JS code instead:

    $("#warehouse tbody" + "").append(
        "<tr>" +
        '<td><input id="idProduct" name="idProduct" value="<%= rs.getString(1) %>" /></td>' +
        '<td><input id="idQuantity" name="idQuantity" value="<%= rs.getString(2) %>" /></td>' +
        '<td><input id="idUnit" name="idUnit" value="cccccc" /></td>' + "</tr>"
    );
    

    This way it ends up in valid JS code like so:

    $("#warehouse tbody" + "").append(
        "<tr>" +
        '<td><input id="idProduct" name="idProduct" value="foo" /></td>' +
        '<td><input id="idQuantity" name="idQuantity" value="bar" /></td>' +
        '<td><input id="idUnit" name="idUnit" value="cccccc" /></td>' + "</tr>"
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a project using Spring Web Flow 2.0. I am trying
I am trying to develop a .NET Web Project using NHibernate and Spring.NET, but
I'm trying to write a program that will fetch data from a SQL Server
I'm working on a Spring 2.0 project, without annotations. We're using several PropertyPlaceholderConfigurer beans
My team working in a project using Winforms application(c#) & MSSQL 2005 as database.
I was working on a project for which i was using curl to fetch
I'm trying to avoid database access in loops within a project I am working
I'm trying to setup a Spring 3 Web MVC project, using the @Controller, annotation-based
I am currently working on a project using jQuery and JavaScript. There will be
I'm working on a project using Windows 2008, .NET 3.5 and WCF for some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.