View Full Version : Increment Textbox using Javascript

Mar 1st, 2013, 02:48 PM
Trying to increment Textbox3 using Javascript in ASP.net.

Not sure how to input a textbox value to count:

Here is the code:

<script type="text/javascript">
function inc() {
var count = document.getElementById("<%=TextBox3.ClientID%>").value;
if (count = "") { count = 0; }
document.getElementById("<%=TextBox3.ClientID%>").value = count + 1;

Mar 1st, 2013, 04:47 PM
If that's not working for you, you might need to cast 'count' as a number.

Also the line
if (count = "") { count = 0; } is not an if statement, you need '==' not '=' to make it an if. What you have sets the variable count equal to zero and your out come for the js code should be the number one in the text box.