PDA

View Full Version : Javascript calculator form



njava88
06 Jul 2009, 06:35 AM
What I'm trying to create is basically a calculator.
In excel it works like this: [website link removed]
The best way would probably be with AJAX, but I'm a javascript beginner.

So the problem is:
I have multiple drop-down boxes for input. How do I store values of selected inputs into a single array when I click the submit button?

Thx in advance!

Alan
07 Jul 2009, 01:46 AM
<script language="JavaScript">
function add(val1,val2) {
var result = val1 + val2;
document.write(result);
}
</script>
<input type="text" name="value1" value=""/>
<input type="text" name="value1" value=""/>
<div onClick="javascript:add(document.value1.value,document.value2.value);">Add</div>


I assume that's what you mean? Now I haven't actually tested this, so my initial thought would be that it doesn't work because of some syntax error but if so, it's not too far from being correct.