Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New to the CF scene
    Join Date
    Aug 2002
    Location
    Bangkok
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    I am having peoblems with this options drop down box

    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


  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    UK
    Posts
    577
    Thanks
    0
    Thanked 0 Times in 0 Posts
    .validation. <<< what's that mean?

    anyway, try

    PHP Code:
    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.
    Ökii - formerly pootergeist
    teckis - take your time and it'll save you time.

  • #3
    Regular Coder
    Join Date
    Jul 2002
    Posts
    226
    Thanks
    0
    Thanked 0 Times in 0 Posts
    <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>

  • #4
    New to the CF scene
    Join Date
    Aug 2002
    Location
    Bangkok
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    thanks guys

    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


  • #5
    New to the CF scene
    Join Date
    Aug 2002
    Location
    Bangkok
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    both solutions work but

    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??????????


  • #6
    Senior Coder
    Join Date
    Jun 2002
    Posts
    1,404
    Thanks
    2
    Thanked 32 Times in 32 Posts
    Code:
    <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>

  • #7
    New to the CF scene
    Join Date
    Aug 2002
    Location
    Bangkok
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Wow that's cool

    Adios your script is superb,

    Short and works 100%

    Thanks


  • #8
    Regular Coder
    Join Date
    Jul 2002
    Posts
    226
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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...


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •