dreamingdigital
03-19-2003, 09:49 PM
Hi.
I know how to call a function this way: example.
<script>
myfunction('my_paramenter');
</script>
This isn't so easy. I want to call a function depending on the value of a menu dropdown option. I'm sending the function call to another function, mychange(), to call it. Confused? Ok here is the code :)
<form name="print">
<select name="mypics" size=1 class="imp" onChange="mychange(this.options[this.selectedIndex].value)">
<option value="aye('pic3','nicola.gif','images/graphics/nicola_large.gif')">PickNic's Bakery
<option value="aye('pic21','titanic.jpg','images/graphics/titanic_large.jpg')">Atlantis VHS Movie Cover Demo
<option value="aye('pic22','ecm.gif','images/graphics/every_canadian_magazine.pdf')">Every Canadian Magazine Demo
</select>
</form>
function aye(thelayer,theimg,thelink) {
var x='<a href="'+ thelink +'" target="_blank"><img src=\"images/graphics/'+theimg+'\" width=300 border=0></a>';
for (var i=0; i<document.layers.length; i++) {
document.layers[i].visibility="hide";
}
document.layers[thelayer].document.open();
document.layers[thelayer].document.write(x);
document.layers[thelayer].document.close();
}
function mychange(perameters?) {
? yeah that's as far as I got.
}
How do I get it from being an <option value> to calling a function?
:thumbsup:
I know how to call a function this way: example.
<script>
myfunction('my_paramenter');
</script>
This isn't so easy. I want to call a function depending on the value of a menu dropdown option. I'm sending the function call to another function, mychange(), to call it. Confused? Ok here is the code :)
<form name="print">
<select name="mypics" size=1 class="imp" onChange="mychange(this.options[this.selectedIndex].value)">
<option value="aye('pic3','nicola.gif','images/graphics/nicola_large.gif')">PickNic's Bakery
<option value="aye('pic21','titanic.jpg','images/graphics/titanic_large.jpg')">Atlantis VHS Movie Cover Demo
<option value="aye('pic22','ecm.gif','images/graphics/every_canadian_magazine.pdf')">Every Canadian Magazine Demo
</select>
</form>
function aye(thelayer,theimg,thelink) {
var x='<a href="'+ thelink +'" target="_blank"><img src=\"images/graphics/'+theimg+'\" width=300 border=0></a>';
for (var i=0; i<document.layers.length; i++) {
document.layers[i].visibility="hide";
}
document.layers[thelayer].document.open();
document.layers[thelayer].document.write(x);
document.layers[thelayer].document.close();
}
function mychange(perameters?) {
? yeah that's as far as I got.
}
How do I get it from being an <option value> to calling a function?
:thumbsup: