function isn't working for some reason! =(

P

PrinceMhul

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.
UseNet rocks so I know someone out there will know :D
 
L

Lee

(e-mail address removed) said:
var objListBox = document.getElementById('catalist');
var val = objListBox[objListBox.selectedIndex].value;
alert("val="+val);

var txt = dyevalue00.value;
alert("txt="+txt);

document.getElementById(val).value = txt;

I must be doing something wrong in my code, since this is n't working.
UseNet rocks so I know someone out there will know :D

What does "isn't working" mean? Are you getting an unexpected
value in the text box? An error message? Nothing happening?

The two alert() lines will help you to pin down whether the problem
is in finding out where to put the value, or in finding what value
to put there. Then you can look to see what's different between
the way you access the control named "catalist" and the control
named "dyevalue00".


--
 
P

PrinceMhul

What I mean by it isn't working is it isn't doing what I intended it to
do. Since I'm new at javascript, everything I do is trial and error.
And if I error too much, I post on here - lol.

What I really need is a way to make it so that if the selected index on
listbox1.value="text1" then I can make the textbox named "text1" (which
text1 is from the listbox.value) equal another textbox's value.

Not sure how to do that though
 
E

Evertjan.

wrote on 03 sep 2006 in comp.lang.javascript:
What I mean by it isn't working is it isn't doing what I intended it to
do. Since I'm new at javascript, everything I do is trial and error.
And if I error too much, I post on here - lol.

What I really need is a way to make it so that if the selected index on
listbox1.value="text1" then I can make the textbox named "text1" (which
text1 is from the listbox.value) equal another textbox's value.

Not sure how to do that though

Are you anwering on something?

Please quote what you are replying to.

<http://www.safalra.com/special/googlegroupsreply/>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top