• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to prevent javascript func from resetting values

 
Edmund Castermund
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a sample form below. The issue I'm having is with a function to validate the form. I have some select tags, and the validate function checks to see if the default values are populated. If they are, it instructs the user to select another value. But when I hit submit, one of the values is changed back to the default value, causing the function to return false. Any idea how to address this?



 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65217
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you used a JavaScript debugger to see at what point things go awry?
 
Edmund Castermund
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried firebug in firefox and the google chrome debugger, nothing. I actually think the function is doing what it's supposed to. Maybe onSubmit isn't the way to go? The thing is, I use this same basic pattern for other forms with no problem. I'm thinking maybe if I change it to a radio selection group that will give me the desired result.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65217
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the function is doing what it's supposed to do, what is the actual problem?
 
Edmund Castermund
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry, not clear with my meaning. I meant that maybe the function is doing what it is instructed to do, but I may be instructing it to do the wrong thing. What I want it to do is leave the select values alone when the validateForm func is called.

Is it possible that when submit is hit, it attempts to send the data and resets the select values? The thing is...it's only the first one that changes. The second is left alone. Any combination I try in terms of the order of the select pulldowns has the same result, the 2nd is left alone and the first goes back to the default value. This behavior is the same in chrome, safari and firefox

thanks,
ec
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65217
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look carefully at line 15.
 
Edmund Castermund
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ugggghhhh.....

one of those moments I want to truly punch myself in the face....



should be




thanks,
ec
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65217
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I didn't see it on first glance either. So forgo the punching.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic