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 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jul 2008
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question text field and select field dependence

    Hi guys! I want to create a form whereby whenever a value is selected from a list of select field it's corresponding value should appear on the text field.
    example,if the select field has a list of file numbers,then if a certain file number is selected the corresponding file name should apppear on the text field

  • #2
    Senior Coder rangana's Avatar
    Join Date
    Feb 2008
    Location
    Cebu City, Philippines
    Posts
    1,752
    Thanks
    65
    Thanked 372 Times in 365 Posts
    Hope this basic example keeps you going:
    Code:
    <script type="text/javascript">
    window.onload=function(){
    var opt=document.getElementById('field');
    opt.onchange=function(){
    document.getElementById('show').value=this.options[this.selectedIndex].text;}
    }
    </script>
    <label for="field">Select Field:</label>
    <select id="field">
    <option>Value 1</option>
    <option>Value 2</option>
    <option>Value 3</option>
    <option>Value 4</option>
    <option>Value 5</option>
    <option>Value 6</option>
    <option>123456789</option>
    </select>
    <input type="text" id="show">
    Learn how to javascript at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph


  •  

    Posting Permissions

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