• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java Script HTML values

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Friends
I have following situation.

I have created JSP page which retrieve data from db. Depending on the rows it retrieves, the HTML page is generated.

For example, it query retrieve 2 rows, the HTML page will dynamically build two rows and display the values accordingly. Let say one the field is qty. As query retruns 2 rows, there will be qty1 and qty2 field in the html page.

I am trying to check for the null values when user presses the update button on the screen which calls servlet. So i have writteen the javascript on the same jsp page.

I am doing following:
<< this gives me the total no of rows
var totalcount = document.whs.icount.value

for (var i =1, i <=totalcount) {
var qty = document.whs.qty +i.value;

}// end for loop
I am getting error when i am trying to join qty and i together. I converted i into string and then tried to join howerver i still didn't succedd.

Can you please help me guys. I am really stuck with this. I have tried everything that i knew about java script and running out of ideas.

thank you very much.

regards,
Rashmi Trivedi
 
Ranch Hand
Posts: 1325
Android Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Rashmi Trivedi:

I am getting error when i am trying to join qty and i together.



what's the error you getting from the browser..? please post you error here in order to help you to resolve this problem..
[ February 07, 2007: Message edited by: Saif uddin ]
 
Muhammad Saifuddin
Ranch Hand
Posts: 1325
Android Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Rashmi Trivedi:
this gives me the total no of rows
var totalcount = document.whs.icount.value

for (var i =1, i <=totalcount) {
var qty = document.whs.qty +i.value;

}// end for loop



one more thing your for loop code is incorrect try to find on google with key word "for loop in javascript" then you will get the right way.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Another thing that is wrong is you are referencing the form element wrong.

document.formName.elements["elementName" + i].value

Eric
 
Rashmi Trivedi
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Eric and Safi
Thank you quick response. It was very useful and Eric's suggestion worked.

Safi: thank you for the for loop suggestions.

Thank you once again..i really appreciate this..

regards,
Rashmi Trivedi
 
reply
    Bookmark Topic Watch Topic
  • New Topic