By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,105 Members | 2,560 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,105 IT Pros & Developers. It's quick & easy.

Actual textbox value not getting set after setting value in Javascript

P: 2
I set the value of Total texbox through javascript, and Total texbox does show the changed value.

But when i access the textbox while saving in the db, the value is reset to previous value (value before calling javascript). The textbox is in the GridView template column.

Expand|Select|Wrap|Line Numbers
  1. function Total(totTxt,sunTxt,monTxt)
  2.  {                  
  3.  var total=0;            
  4. var tot=document.getElementById(totTxt);    
  5. var sun = document.getElementById(sunTxt);
  6. var mon = document.getElementById(monTxt);
  7. total = parseFloat(sun.value) + parseFloat(mon.value)
  8. tot.value = total;     
Sep 7 '10 #1
Share this Question
Share on Google+
2 Replies

Expert Mod 5K+
P: 8,639
you do a regular form submit (i.e. no AJAX)?
Sep 7 '10 #2

P: 2
Thanks for reply.

I just figured out that since i have made "totTxt" as "Disabled=true", whatever value i assign is not taken and reset to original value!!

Then i removed "Disabled=true" and made totTxt as Readonly=true. It worked fine.
Sep 7 '10 #3

Post your reply

Sign in to post your reply or Sign up for a free account.