View Full Version : Dropdown instead of...


Dolan
05-15-2003, 04:17 PM
... multiple fields. Didn't know if I should post here or in the Javascript section...
This is how my code looks like:

<form name="one">
<font color="white" size="2">One:
<input type="text" name="input">
<input type="button" onClick="wone(one.input.value);" value="Calculate!">
<font color="white" size="2">Price:
<input type="text" name="output" disabled="disabled">
</form>

<form name="two">
<font color="white" size="2">Two:
<input type="text" name="input">
<input type="button" onClick="wtwo(two.input.value);" value="Calculate!">
<font color="white" size="2">Price:
<input type="text" name="output" disabled="disabled">
</form>

<form name="three">
<font color="white" size="2">Three:
<input type="text" name="input">
<input type="button" onClick="wthree(three.input.value);" value="Calculate!">
<font color="white" size="2">Price:
<input type="text" name="output" disabled="disabled">
</form>

<form name="four">
<font color="white" size="2">Four:
<input type="text" name="input">
<input type="button" onClick="wfour(four.input.value);" value="Calculate!">
<font color="white" size="2">Price:
<input type="text" name="output" disabled="disabled">
</form>

<script type="text/javascript">
function wone(w) {
one.output.value = Math.floor(180000000 / w);
}
function wtwo(w) {
two.output.value = Math.floor(95000000 / w);
}
function wthree(w) {
three.output.value = Math.floor(45000000 / w);
}
function wfour(w) {
four.output.value = Math.floor(165000 / w);
}
</script>


Anyone that can help me? I need a dropdown menubox insted of all the fields.

zangerbanger
05-15-2003, 10:48 PM
http://www.lissaexplains.com/fun.shtml#drop ?

Dolan
05-16-2003, 04:12 AM
I've seen that, but I don't know how to get it to work.

zangerbanger
05-16-2003, 04:14 AM
Could you please post the code you are using?

Dolan
05-16-2003, 04:16 AM
??? I have...

<form name="one">
<font color="white" size="2">One:
<input type="text" name="input">
<input type="button" onClick="wone(one.input.value);" value="Calculate!">
<font color="white" size="2">Price:
<input type="text" name="output" disabled="disabled">
</form>

<form name="two">
<font color="white" size="2">Two:
<input type="text" name="input">
<input type="button" onClick="wtwo(two.input.value);" value="Calculate!">
<font color="white" size="2">Price:
<input type="text" name="output" disabled="disabled">
</form>

<form name="three">
<font color="white" size="2">Three:
<input type="text" name="input">
<input type="button" onClick="wthree(three.input.value);" value="Calculate!">
<font color="white" size="2">Price:
<input type="text" name="output" disabled="disabled">
</form>

<form name="four">
<font color="white" size="2">Four:
<input type="text" name="input">
<input type="button" onClick="wfour(four.input.value);" value="Calculate!">
<font color="white" size="2">Price:
<input type="text" name="output" disabled="disabled">
</form>

<script type="text/javascript">
function wone(w) {
one.output.value = Math.floor(180000000 / w);
}
function wtwo(w) {
two.output.value = Math.floor(95000000 / w);
}
function wthree(w) {
three.output.value = Math.floor(45000000 / w);
}
function wfour(w) {
four.output.value = Math.floor(165000 / w);
}
</script>

zangerbanger
05-16-2003, 04:19 AM
I don't understand what you're exactly trying to do. If you want a drop-down menu, use Lissa's code on her page:

http://www.lissaexplains.com/fun.shtml#drop

Dolan
05-16-2003, 04:23 AM
How do I use it with the script I have?

Dolan
05-16-2003, 05:05 AM
I've tried this:

<form name="weps">
<select name="calc" size=1 >
<option value="wone">One</option>
<option value="wtwo">Two</option>
<option value="wthree">Three</option>
<option value="wfour">Four</option>
</select>
<input type="button" onClick="document.weps.calc.options
[document.weps.calc.selectedIndex].value(weps.input.value);"
value="Calculate">
<input type="text" name="input">
Price: <input type="text" name="output" disabled="disabled">
</form>

<script type="text/javascript">
function wone(w) {
weps.output.value = Math.floor(180000000 / w);
}
function wtwo(w) {
weps.output.value = Math.floor(95000000 / w);
}
function wthree(w) {
weps.output.value = Math.floor(45000000 / w);
}
function wfour(w) {
weps.output.value = Math.floor(165000 / w);
}
</script>

Why doesn't this work?

Dolan
05-16-2003, 11:51 AM
Got help with it, so it works. Thanx anyway.