Anyways, what I am trying to do, is use a form, and have JavaScript find the value of a selected option in a select element, and load that into a function.
In my case, I have made a dynamic image compiler (or whatever you want to call it), and I have a previewer table. I use a pic() function that simply changes the image source of an image in the preview table, simple stuff.
Now, I have one select menu where you can choose your hair, and another where you can have a head accessory. But, then I have a helmet you can choose from, and using logic, your hair wouldn't be visible (in the game its for anyways) and you obviously can't have a head accessory like a cavalier on your head at the same time. So, I have when a helmet is selected, it changes the hair slot to the helmet preview picture, and make the head accessory null (src=''). Now, this can be frustrating though, if someone decides they don't want the helmet. They have to re-click on the hair and head accessory for them to show in the table again. I want so that they simply click 'None' in the helmet select menu, and it will revert the hair and accessory slots back to the values of the respective select menus.
First off, here is the page.
Ok, so I tried to make my own function, similar to the pic() function I was using, and this is what it looks like.
function revert(img_name) {
var getImg = document.getElementById[img_name].value;
getImg = getImg + ".png";
document[img_name].src = "dinty_kit/previews/" + img_name + "/" + getImg;
}
I figured I could simply pass it the image id, and it would be able to put it into this code and it would be alright. But nothing happens when I click it.
Here is how I am trying to use it.
<option value="none" onclick="revert('hair'); revert('head');" selected="selected">None</option>
I have my id's and name and all set properly, I suspect it just has to do with my function. I'm terrible at JavaScript.
Is what I'm trying even possible? I've seen how JavaScript can return the value of something using that DOM object reference, but Im just not sure if I'm using it correctly...
Edited by Demonslay, 09 July 2006 - 12:53 AM.
