...

View Full Version : passing 1 variable containing 3 parameters



snate
05-14-2009, 10:51 PM
New to this bare with me.




myfunction(a,b,c)
{
do something;
}


<select onChange="myfunction(document.getElementById('selectid').value)">
<option value="'cool','dude',3"> Hee </option>
<optiion value="'some','dif',2"> Haa </option>
</select>

snate
05-14-2009, 11:00 PM
I figured a way out, but if there is a better way would like to see that




myfunction(a,b,c)
{
do something;
}


<select onChange="eval(document.getElementById('selectid').value)">
<option value="myfunction('cool','dude',3)"> Hee </option>
<optiion value="myfunction('some','dif',2")> Haa </option>
</select>

Old Pedant
05-14-2009, 11:11 PM
Not sure it's necessarily better in any way, but:


<select onChange="var e = this.value.split(/::/g);myfunctin(e[0],e[1],parseInt(e[2]);">
<option value="cool::dude::3"> Hee </option>
<optiion value="some::dif::2")> Haa </option>
</select>

If this is the only place myfunction is called, I'd just rewrite the function to take the delimited string and do the split inside the function. The choice of delimiter is of course up to you, so long as it doesn't appear in any of the elements.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum