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

set value won't work

100+
P: 178
Hi,

Can't see where I have went wrong with this line of code. What I want to do is everytime this box gets focus I want a default value of 1 to be shown.

[HTML]<input type = "text" value = "1" name = "quantity" id = "quantity" onfocus="document.getElementById('quantity').value = 1"></td>[/HTML]

It is fine the first time as the value is already declared but on each attempt after it doesn't show
Oct 9 '08 #1
Share this Question
Share on Google+
3 Replies


acoder
Expert Mod 15k+
P: 16,027
It should work, though you could use this.value and use a string instead of an integer. Check the ID is unique. Are there any errors?
Oct 9 '08 #2

100+
P: 178
thanks, using this.value did the trick
Oct 9 '08 #3

acoder
Expert Mod 15k+
P: 16,027
Good. Glad it's working :)
Oct 9 '08 #4

Post your reply

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