Jump to content

no properties


Flic

Recommended Posts

This is probably going to be one of those silly little things, but if it is could someone point it out as for the life of me I can't see it!I have the following code, part of it works part of it doesn't:

function changeColour() {var selection = (document.select.colour.selectedIndex);var picture = ((document.select.colour.options[selection].value) + ".jpg");var text = ((document.select.colour.options[selection].value) + "Text");document.colour.src = picture;document.text.style.display = "";}

The picture section of it works fine, however the style bit doesn't, I get "document.text has no properties", I know what it is telling me but I don't know why it is telling me that.The code works if I substitute in the name but obviously I don't want to do that!Any help appreciated!

Link to comment
Share on other sites

Let us discuss, by examining line by line...say the drop down has 3 values via.. red, blue and greenand consider blue is selected.var selection = (document.select.colour.selectedIndex);--> selection is equal to 1.var picture = ((document.select.colour.options[selection].value) + ".jpg");--> picture is equal to "blue.jpg"var text = ((document.select.colour.options[selection].value) + "Text");--> text is equal to "blueText"document.colour.src = picture;document.text.style.display = "";--> here the text is taken as an attribute itself and hence your requirment of embedding the 'blueText' is not done.(correct me if iam wrong in understanding ur req.)

Link to comment
Share on other sites

Let us discuss, by examining line by line...say the drop down has 3 values via.. red, blue and greenand consider blue is selected.var selection = (document.select.colour.selectedIndex);--> selection is equal to 1.var picture = ((document.select.colour.options[selection].value) + ".jpg");--> picture is equal to "blue.jpg"var text = ((document.select.colour.options[selection].value) + "Text");--> text is equal to "blueText"document.colour.src = picture;document.text.style.display = "";--> here the text is taken as an attribute itself and hence your requirment of embedding the 'blueText' is not done.(correct me if iam wrong in understanding ur req.)

Thats right. The style should affect a form that I have on the same page. Any idea how to fix it? I'm out of ideas right now!
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...