|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
help with javascript & HTML DOM
hi,
I have a form that, when a button is clicked, it sends the info to a js function that is supposed to add the number "3" to the textbox on the form. Can someone please tell me what I should do to make it work... Code:
<head>
<script language="javascript">
function fnNum(numText)
{
var x = document.myForm.num.value
x = x + ""
document.myForm.num.value=x+numText
}
</script>
</head>
<body>
<form id="myForm">
<input type="text" name="num">
<button type="button" id="myButton" value="3" onClick="fnNum(this.value)">3</button>
</form>
</body>
|
|
#2
|
||||
|
||||
|
Code:
<head>
<script language="javascript">
function fnNum(intNumber) {
var x = parseInt(document.myForm.num.value);
x = x + parseInt(intNumber);
document.myForm.num.value = x;
}
</script>
</head>
<body>
<form id="myForm">
<input type="text" id="num">
<input type="hidden" id="numberToAdd" value="3">
<input type="button" value="+? Button" id="numberButton" onClick="fnNum(document.myForm.numberToAdd.value)">
</form>
</body>
__________________
If you found a post of mine helpful, please click on the on my post to add to my reputation.
|
![]() |
| Viewing: ASP Free Forums > Programming > HTML, JavaScript And CSS Help > help with javascript & HTML DOM |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|