I am having trouble returning things from this function. Below is the function.

function switchframeAQUA(v) {
	if (v == "0") {
	document.getElementById("picframe").src = "/frames/cod-liver-oil_pic.html"; 
	document.getElementById("blurbframe").src = "/frames/cod-liver-oil_blurb.html";
	} else if (v == "1") {
	document.getElementById("picframe").src = "/frames/fish-oil_pic.html";
	document.getElementById("blurbframe").src = "/frames/fish-oil_blurb.html";
	} else if (v == "2") {
	
	} else if (v == "3") {
	
	} else if (v == "4") {
	
	} else if (v == "5") {
	
	} else if (v == "6") {
	
	} else if (v == "7") {
	
	} else if (v == "8") {
	
	} else if (v == "9") {
	
	} else if (v == "10") {
	
	} else if (v == "11") {
	
	} else {
	document.getElementById("picframe").src = "/frames/cod-liver-oil_pic.html";
	document.getElementById("blurbframe").src = "/frames/cod-liver-oil_blurb.html";
	}
};

This below, is where this is called and the entire system. Just so you can all get the basic idea :D

<select name="aqua" style="width: 160px" class="auto-style5" onchange="switchframeAQUA(aqua.options[this.SelectedIndex].value)">
				<option value="0" >Cod liver oil</option>
				<option value="1" >Fish oil</option>
				<option value="2">Evening Primrose oil</option>
				<option value="3">Evening Primrose + Starflower oil</option>
				<option value="4">Starflower oil</option>
				<option value="5">Linseed oil</option>
				<option value="6">Super Multi Minerals</option>
				<option value="7">Magnesium + Vit B6</option>
				<option value="8">Flaxseed oil</option>
				<option value="9">Omega 3/6/9 Blend (Organic)</option>
				<option value="10">Flaxseed oil (Organic)</option>
				<option value="11">Super Multi Minerals</option>
				</select>

This doesn't do anything!
Seriously, nothing is returned at all and nothing changes.

Any help would be much appreciated as I have tried working at this for nearly two days now =[

Cheers!
Jack

The function doesn't return anything (it doesn't have a return statement), neither does it need to return anything.

The problem occurs where the function is called.

Try:

<select name="aqua" style="width: 160px" class="auto-style5" onchange="switchframeAQUA(this[this.selectedIndex].value)">

Airshow

Brilliant, thank you Airshow, you are a legend!

I knew it would be something so simple :D It worked as needed!

Well, that bit of code in the onchange, was from a tut, so I shall get in touch with them to tell them it isn't quite correct depending on where it is being used.

Once again, cheers for the help Airshow!!!!!

Jack

Scaasiboi,

:cool:

With a capital "S" in ".SelectedIndex", it could never have worked. Javascript variables and properties are case-sensitive and selectElementNode.SelectedIndex doesn't exist; moreover selectElementNode[selectElementNode.SelectedIndex].value will throw an error. Your browser should have an error console unless it's bog standard IE, which throws its errors into popup windows (when turned on).

Apart from that, it may have worked in IE but certainly not other browsers. My code should work in all the major browsers but please don't take my word for it (I am fallible). Do some testing.

Airshows

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.