...

View Full Version : I am having peoblems with this options drop down box



shadiadi
08-20-2002, 01:47 PM
Hi there,

I am having a problem with this script.
Here is what it is supposed to do.

When I select a number the value of that number i.e 1 = 275.00
should appear in the second empty box.

Here is the script.

<html>
<title></title>

<head>
<script language="javascript">
function myjunk ()
{
var hat = this.document.validation.myname.selectedIndex
var hatto = this.document.validation.myname.options[hat].value

if (hatto != 'Select one') {
this.document.validation.myformname.value = hatto
this.document.validation.myname.options[0].selected=true
}

}
</script>

</head>
<body>
<form name="myformname">
<select name="myname" onchange="myjunk();">
<option value="Select one">Select a number</option>
<option value="275.00">option 1 - 275.00</option>
<option value="550.00">option 2 - 550.00</option>
<option value="825.00">option 3 - 825.00</option>
<option value="1100.00">option 4 - 1100.00</option>
<option value="1375.00">option 51375.00</option>
</select>

<input type="text" name="myformname">

</form>

</body>
</html>


Can anyone see what is wrong with it or have a better idea to approach this?

It will be much appreciated

:confused:

Íkii
08-20-2002, 02:23 PM
.validation. <<< what's that mean?

anyway, try


function myjunk() {
akth = document.forms["myformname"].elements["myname"].value;
if (akth!=="Select one") {
document.forms["myformname"].elements["myformname"].value = akth;
document.forms["myformname"].elements["myname"].options[0].selected=true;
}
}

Note: perhaps calling the text input a different name from 'myformname' might be sensible.

Squintz
08-20-2002, 02:24 PM
<html>
<title></title>

<head>
<script language="javascript">

function myjunk()
{
var hat = this.document.myformname.myname.selectedIndex
var hatto = this.document.myformname.myname.options[hat].value

if (hatto != 'Select one') {
this.document.myformname.mytextname.value = hatto
this.document.myformname.myname.options[0].selected=true
}

}
</script>


I hate when that happens...Oh well i learned from troubleshooting this so it was owrth the post....

</head>
<body>
<form name="myformname">
<select name="myname" onchange="myjunk();">
<option value="Select one">Select a number</option>
<option value="275.00">option 1 - 275.00</option>
<option value="550.00">option 2 - 550.00</option>
<option value="825.00">option 3 - 825.00</option>
<option value="1100.00">option 4 - 1100.00</option>
<option value="1375.00">option 51375.00</option>
</select>

<input type="text" name="mytextname">

</form>

shadiadi
08-20-2002, 02:35 PM
Thanks alot.

Sqintz your modification to my messed up script is great it works a treat.

Now I am going to go off and work out where I went wrong on the first one.

Thanks once again I am not at all familiar with php it's a bit like double dutch to me.

Much appreciated

:thumbsup:

shadiadi
08-21-2002, 01:16 AM
Both of those solutions work but why does the drop down box always jump back to the default vaule once you have selected one. You select 4 and it jumps back to Select One every time in both solutions??????????


Is there a way around this??????????

:confused: :confused:

adios
08-21-2002, 02:35 AM
<html>
<title></title>
<head>
</head>
<body>
<form>
<select onchange="showit.value=this[this.selectedIndex].value">
<option value="">Select a number</option>
<option value="275.00">option 1 - 275.00</option>
<option value="550.00">option 2 - 550.00</option>
<option value="825.00">option 3 - 825.00</option>
<option value="1100.00">option 4 - 1100.00</option>
<option value="1375.00">option 51375.00</option>
</select>
<input type="text" name="showit">
</form>
</body>
</html>

shadiadi
08-21-2002, 01:58 PM
Adios your script is superb,

Short and works 100%

Thanks

:thumbsup: :thumbsup: :thumbsup: :thumbsup: :thumbsup:

Squintz
08-21-2002, 04:37 PM
in adios code he uses the TERM "this"... what are the rules for using "this"... in other words what does "this" refer to and in what other ways can "this" be used...



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum