• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Drop down box to load various swf's


tbwcf

Active Member
#1
I'm building a webpage where where is a coverflow/slideshow of various mailer designs.

There will be about 200 so it will need splitting up into various sections.

Can anyone advise me on how to get some sort of dropdown menu/buttons to load different swfs into a div in the page please?
 

Jazajay

Active Member
#2
Well I take it you want to accomplish this via JavaScript?
Use the onchange event handler and grab the selected value, then pass it to a Ajax function, and load the file into a div if that 1 is selected.

So something like ~

HTML
<select onchange="change()">
<option value="movie1.swf"....
<option value="movie2.swf"....
</select>

JavaScript
function change(){
var form=document.getElementsByTagName("form")[0]; //selects the first form.
var selection=form.elements[form.getElementsByTagName('select')[0]]; //select the first select menu within the first form.
var val=selection.selectedIndex; //gets the selected option.
call("path/to/swf/file.swf","id you want to load the swf files into","selection="+selection.options[val].value,"Please wait while we load the flash movie"); //sends the value of the option to the swf file.
}

File.swf
Then list the .swf files and test to see which one you want to send back, so for example ~
<?php
if(isset($_POST['selection'])){
$a=$_POST['selection'];
if($a=="movie1.swf"){?>

<object.......
<?php }elseif($a=="movie2.swf"){?>
<object......
<?php }elseif(.....
}
?>


Right now that looks fine, if you get an error let me know as I have have just wrote it off the cuff.
Here's my AJAX function if you need it, and if you have the files in a DB then you can just simply loop through the results rather than listing each one.

Then have a button that when pressed loads a separate page but also does the same thing, that way it works across the board.

I would say though that if every page is going to be similar, except from the .swf file, that you should place the meta noindex on those pages so not to be penalized for duplicate content.

Any problems, or not what you are looking for let me know.

Hope it helps.
Jaz

Key:
Purple ~ XHTML
Orange ~ Comments (dont place in the code)
Green ~ JavaScript
Red ~ PHP
 

Jazajay

Active Member
#7
Hay error correction ~
Change the above JavaScript function to ~
function change(){
var form=document.getElementsByTagName("form")[0]; //selects the first form.
var selection=form.elements[form.getElementsByTagName('select')[0]]; //select the first select menu within the first form.
var val=selection.selectedIndex; //gets the right option value.
call("path/to/swf/file.swf","id you want to load the swf files into","selection="+selection.options[val].value,"Please wait while we load the flash movie"); //sends the value to the swf file.
}

As we want the contents of the value attribute.

Changed in the above code.
Any other problems let me know.

Jaz

Key:
Green ~ JavaScript
Orange ~ Comments (Don't include in the actual code.)