DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   ASP (http://www.daniweb.com/forums/forum62.html)
-   -   text box value in asp (http://www.daniweb.com/forums/thread50263.html)

kdv Jul 17th, 2006 4:04 am
text box value in asp
 
hi plz tell me how to increment textbox value by 1 whenever click submit button in asp.Example let say now my text box value is 1.When user click submit the text box value must change to 2 and so on.Plz reply me. thanx in advance;)

terrencetaylor7 Jul 21st, 2006 1:08 pm
Re: text box value in asp
 
oops...

terrencetaylor7 Jul 21st, 2006 1:13 pm
Re: text box value in asp
 
sorry, continued.
<script language="JavaScript">
function addone(){
textbox1.value=eval(textbox1.value + 1)
form1.submit()
}</script>
[html]
<form method="post" action="somepage.asp" onSubmit="addone()"><input type="text" name="textbox1"><input type="submit" value="submit"></form>[/html]

Or more like:
<script language="JavaScript">
function addone(){
textbox1.value=eval(textbox1.value + 1)
}</script>
[html]
<input type="text" name="textbox1"><input type="Button" value="submit" onClick="addone()"></form>[/html]

kdv Jul 21st, 2006 10:50 pm
Re: text box value in asp
 
Quote:

Originally Posted by terrencetaylor7
sorry, continued.
<script language="JavaScript">
function addone(){
textbox1.value=eval(textbox1.value + 1)
form1.submit()
}</script>
[html]
<form method="post" action="somepage.asp" onSubmit="addone()"><input type="text" name="textbox1"><input type="submit" value="submit"></form>[/html]

Or more like:
<script language="JavaScript">
function addone(){
textbox1.value=eval(textbox1.value + 1)
}</script>
[html]
<input type="text" name="textbox1"><input type="Button" value="submit" onClick="addone()"></form>[/html]

Hi thanx for ur response.Its really helpful.But now I,m facing another problem.Im having one combobox.Once user choose item in combobox, the selected item must be display in textbox with an autonumber.For example:
If combobox value is A.textbox value must be A1.Once user submit,and user choose another item in combobox the item (let say B) textbox must display B2.hope u understand my question.Thanx in advance.Plz post me as soon as possible.Because I need to finish tis function as earlier as possible.

terrencetaylor7 Jul 22nd, 2006 9:39 am
Re: text box value in asp
 
I think this will do it. Tell me what you think...
[html]
<html><head>
<script language="JavaScript">
function addone(){
form1.counter1.value=eval(form1.counter1.value) + 1
form1.submit()
}</script>
</head><body>
<%
countsofar = CInt(Request("counter1"))
ddselected = CStr(Request("dropdown1"))
textbox1now = ddselected & countsofar
%>
<form method="post" action="test.asp" name="form1">
<select name="dropdown1">
<option value="a" <%if ddselected="a" then response.write("selected") end if%>>a</option>
<option value="b" <%if ddselected="b" then response.write("selected") end if%>>b</option>
<option value="c" <%if ddselected="c" then response.write("selected") end if%>>c</option>
</select>
<input type="text" name="textbox1" value="<%=textbox1now%>">
<input type="hidden" name="counter1" value="<%=countsofar%>">
<input type="button" value="submit" onClick="addone()">
</form>
</body></html>
[/html]

bala_friendd Jul 26th, 2006 1:51 am
Re: text box value in asp
 
[quote=kdv]hi plz tell me how to increment textbox value by 1 whenever click submit button in asp.Example let say now my text box value is 1.When user click submit the text box value must change to 2 and so on.Plz reply me. thanx in advance;)[/quote


iam sending the coding copy pste in ur applcation

function ChkZero(x) { if(x == "") return 0; else return x; }
function calc(el1,el2,el3,el4) { var a = ChkZero(eval("document.frmansadd."+el1).value); var b = ChkZero(eval("document.frmansadd."+el2).value); var c = ChkZero(eval("document.frmansadd."+el3).value); d = parseInt(a)+parseInt(b)+parseInt(c) eval("document.frmansadd."+el4).value=d; }


All times are GMT -4. The time now is 9:46 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC