This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes Not checking the other conditions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Not checking the other conditions" Watch "Not checking the other conditions" New topic
Author

Not checking the other conditions

pankaj semwal
Ranch Hand

Joined: Oct 07, 2008
Posts: 300

Hi,

This my java script code.But this code show only document.getElementById(id).value =SP;
value in my jsp page.After that it does not check other conditions.
Pleas help me what the problem, in this code.


Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1321

Hi,

Didn't get what you are really want to achieve.. would you please make simpler.



Saifuddin..
[Blog][Linkedin] How To Ask Questions On JavaRanch My OpenSource
pankaj semwal
Ranch Hand

Joined: Oct 07, 2008
Posts: 300
Hi,
This is my code sample on the change event of
<input type="text" name="workorder.unitRate" value="" id="unitRate" onchange="putvalue();"/>

the values in these text boxes are not populating.

input type="text" name="statId0" value="" id="workorderlist_statId0"/>
input type="text" name="statId0" value="" id="workorderlist_statId0"/>
input type="text" name="statId0" value="" id="workorderlist_statId0"/>
input type="text" name="statId0" value="" id="workorderlist_statId0"/>

Please help me.


Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

pankaj semwal wrote:
This my java script code.But this code show only document.getElementById(id).value =SP;
value in my jsp page.After that it does not check other conditions.


That's normal for if-else statements. Once the test value in an if-clause is true, then its associated statement (in your case document.getElementById(id).value =SP) is executed and the else-clause is not executed. Since those "other conditions" are in the else-clause, they don't get executed.
pankaj semwal
Ranch Hand

Joined: Oct 07, 2008
Posts: 300
hi,
Then what i have to made the change in the function so that the values of the other text boxes should print.

Thanks
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

I didn't see any text boxes in your original post. Your follow-up, which was supposed to "simplify" the question, was way too long to read. It would help if you could come up with a small example and a question about that example.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
HTML Specs says IDs have to be singular so your code is invalid so getElementById will fail.

edit[I think you had copy/paste error with your subset of code. ]

Eric

Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
The JavaScript error is

TypeError: document.getElementById("record").rows[i].cells[1] is undefined

JavaScript 101 debugging should give you more info, add a debugging statement in your loop:



Eric
pankaj semwal
Ranch Hand

Joined: Oct 07, 2008
Posts: 300
Hi,
I am not understanding this "HTML Specs says IDs have to be singular so your code is invalid so getElementById will fail. "

Can you explain this.


Thanks
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
pankaj semwal wrote:Hi,
I am not understanding this "HTML Specs says IDs have to be singular so your code is invalid so getElementById will fail. "

Can you explain this.


Thanks


When you typed up your question you copy and pasted id="workorderlist_statId0 a bunch of times and never changed it. Hence why I thought you used the same ID 5 times.

Eric
 
Consider Paul's rocket mass heater.
 
subject: Not checking the other conditions
 
Similar Threads
JS error - Message: Member not found
MultiDimenaional Array sort
document.getElementByID() not working in IE8
Having trouble with a javascript assignment
Dynamic AJAX control