Forum Moderators: open
<form name="order">
<input type="text" name="name" />
¦¦¦¦¦¦¦¦¦More fields¦¦¦¦¦¦¦¦¦¦
¦¦¦¦¦¦¦¦¦More fields¦¦¦¦¦¦¦¦¦¦
¦¦¦¦¦¦¦¦¦More fields¦¦¦¦¦¦¦¦¦¦
¦¦¦¦¦¦¦¦¦More fields¦¦¦¦¦¦¦¦¦¦*Javascript code to display the value of name"
</form>
This is what I currently have, which doesn't work:
<script language="JavaScript">
<!--
function showData()
{ document.write(document.order.name.value);
}
//-->
</script>
when the value of name is changed, it goes to a new document with the value, how do I make it write the value without changing the rest of the document?
Your help is greatly appreciated!
<form name="order">
<input type="text" name="name" onkeyup="showData(this)"/>
<div id="total"></div>
</form>
<script type="text/javascript">
function showData(obj) {
document.getElementById("total").innerHTML = obj.value;
}
</script>
OR if you wanted to generate the total of all fields:
function showData(obj) {
var f = obj.form;
var total = 0;
for(i=0; i<f.elements.length; i++){
if(f.elements[i].type == "text") total = (parseInt(f.elements[i],10)!= "NaN")? total + parseInt(f.elements[i],10) : total;
}
document.getElementById("total").innerHTML = total;
}
- JS
<div id="total"></div>
<script type="text/javascript">
function showData(obj)
{
document.getElementById("total").innerHTML = obj.value;
}
</script>
<div id="totalb"></div>
<script type="text/javascript">
function showDatab(obj)
{
document.getElementById("totalb").innerHTML = obj.value;
}
</script>
how do I multiply the outpu of those two?