PDA

View Full Version : How to involve more than one id in a call funtion code...



google503
03-03-2008, 07:43 PM
How do you involve more than one ids in a call function code?

This is what i've got so far (cut down):


<head>
<script type="text/javascript" language="javascript">
function show (name)
{
var mydiv = document.getElementById(name);

mydiv.className = "displayed";
}
</script>
</head>
<body>
.....<option value="2" onclick="show('page1')">1</option><option value="3" onclick="show('page1','page2')">2</option>


Where it says page 1 i'd also like there to be page 2 3 4,5 etc.
I've tried writing "show('page1','page2','page3'..." but it doesn't work...

How can I do this?

mjlorbet
03-03-2008, 07:52 PM
function showBatch (names)
{
var tNames = names;
while(tNames.indexOf(",") != -1){
show(tNames.substr(0, tNames.indexOf(",")));
tNames = tNames.substr(tNames.indexOf(",") + 1);
while(tNames.indexOf(" ") == 0)
tNames = tNames.substr(1);
}
}



use it like showBatch("page1, page2, page3")

mjlorbet
03-03-2008, 07:53 PM
sorry, that won't show the last one, if you want to take the lazy route, just add a comma to the end of the string (eg. "page1, page2, page3,")