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

    textbox / listbox relationship function problem

    Code:
    var objListBox = document.getElementById('catalist');
    var val = objListBox[objListBox.selectedIndex].value;
    var txt = dyevalue00.value;
    document.getElementById(val).value = txt;
    Now I'm very new at this, and I've done much research to try to find this answered and could not. So let me explain in detail what I'm trying to do, maybe someone could shed light on the situation?

    To explain real quick, this is for a character maker.
    The "catalist" is a listbox with different values such as "Body1" -
    "Head" - "Shoes" - "Hair" etc
    "dyevalue00" is a textbox id.
    I have many textboxes that are named the same as the "catalist" values
    (like textboxes named Body1 - Head - Shoes - Hair - etc..

    So if the selected value on CataList is "hair", then I want the textbox that has the id of "hair" to equal whatever is inside the textbox with the id of
    "dyevalue00".

    I must be doing something wrong in my code, since this isn't working. =(
    I was thinking possibly if, else if statements would work but I can't seem to figure that out either. The site currently only works in firefox (I know ) but the link is www.cnex.us/sandbox/demo.html if you want to see kinda the layout to get an understanding. Thanks again guys =)

    edit: A better way to describe this in simple terms would be that I need a way to make it so that if listbox1.value="text1" then I can make the textbox named "text1" equal another textbox.value
    Last edited by Nagnag; 09-03-2006 at 01:43 PM.

  • #2
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,503
    Thanks
    3
    Thanked 500 Times in 487 Posts
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
    
    <html>
    
    <head>
      <title></title>
    <script language="JavaScript" type="text/javascript">
    <!--
    
    function Cng(obj,tb){
     obj.form[obj.value].value=obj.form[tb].value;
    }
    
    //-->
    </script></head>
    
    <body>
    <form>
    <input name="TB1" value="1234" ><br>
    <select onchange="Cng(this,'TB1');" >
    <option value="Tom" >Tom</option>
    <option value="Dick" >Dick</option>
    <option value="Harry" >Harry</option>
    </select>
    <br>
    <input name="Tom" ><br>
    <input name="Dick" ><br>
    <input name="Harry" ><br>
    </form>
    </body>
    
    </html>
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/

  • #3
    New to the CF scene
    Join Date
    Sep 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks very much! I need someone like you that speaks js fluently to help me with my site, haha :P
    Last edited by Nagnag; 09-04-2006 at 12:00 PM.


  •  

    Posting Permissions

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