View Full Version : textbox / listbox relationship function problem

09-03-2006, 02:41 PM
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

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

09-03-2006, 06:06 PM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"


<script language="JavaScript" type="text/javascript">

function Cng(obj,tb){


<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>
<input name="Tom" ><br>
<input name="Dick" ><br>
<input name="Harry" ><br>


09-04-2006, 12:46 PM
Thanks very much! :D I need someone like you that speaks js fluently to help me with my site, haha :P