PDA

View Full Version : function isn't working for some reason! :(


Nagnag
09-02-2006, 10:58 PM
var objListBox = document.getElementById('catalist');
var val = objListBox[objListBox.selectedIndex].value;
var txt = dyevalue00.value;
document.getElementById(val).value = txt;

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
I have many textboxes that are named the same as the "catalist" values
(like textboxes named Body1 - Head - Shoes - Hair - etc..

So whatever is selected in "CataList" (let's say Hair) I want that
textbox to equal what another textbox of mine equals. 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 is n't working.
HTMLforums rocks so I know someone out there will know :D

blackpepper
09-02-2006, 11:17 PM
you may of got faster replys if you put this in the client side forum.
what about trying something like this,(sry if i missed what you were after or this doesnt work)
var objListBox = document.getElementById('catalist');
var val = objListBox[objListBox.selectedIndex].value;
var txt = dyevalue00.value;
var newval = document.getElementById(val).value = '' + txt + '';

Nagnag
09-02-2006, 11:50 PM
That doesn't seem to work either.
What I really need is a way to make it so that if listbox1.value="text1" then I can make the textbox named "text1" equal another textbox.value

Not sure how to do that though

blackpepper
09-03-2006, 12:13 AM
is listbox a textbox or a list?

Nagnag
09-03-2006, 12:18 AM
listbox is a list. like a dropdown menu
thats why I used the selectedIndex function
But it doesn't seem to be working =(

blackpepper
09-03-2006, 09:09 PM
how about something liek this..

function changes(){
var objListBox = document.getElementById('catalist');
var val = objListBox[objListBox.selectedIndex].value;
var txt = dyevalue00.value;
var val2 = document.formname.mastertxtbox.value;
if(val = "text1"){
document.formname.text1.value = '' + val2 + '';
}}
youd have to customize the form names and input names that are in bold
if not do you have a link to all your other html and javascript?