www.webdeveloper.com
Results 1 to 2 of 2

Thread: Javascript: Array generated Dropdown with video change.

  1. #1
    Join Date
    Jan 2010
    Posts
    5

    Javascript: Array generated Dropdown with video change.

    Hello, i am all new to this kind of stuff and i didnt find any topic yet about it because i do not really know how to call this problem. So if there are any solutions yet i am sorry for opening a new topic.

    I want a dropdown navigation, that read its content out of an array.
    best would be if the array could read its content out of a .txt file but i know that this is kinda impossible via javascript.

    But there is gonna be a special part about the dropdown. Above the dropdown there is a embeded youtube video.
    This is a randomly shown youtube video, by letting php generate a random number, picking a video-link out of the array-file and putting the link into this embeded code.

    NOW^^ if the user chooses a link in the dropdown it should change the above video code by putting in not the random number but the choosed one.

    I hope you understood what i was trying to ask

    Thats what i got so far...its all PHP i know, but i do not know how to realize it with javascript, thats why i ask it here.
    Code:
    <?php
    
    $video_array = file('vid.txt');
    $zahl_array = file('zahl.txt');
    $anzahl = count($video_array);
    
    
    // random zahl f&#252;r alle arrays gleich
    $num = rand(0, count($video_array) - 1);
    $video = $video_array[$num];
    $zahl = $zahl_array[$num];
    
    //Trimmen
    $zahl = trim($zahl);
    $video = trim($video);
    
    ?>
    
    <table border="0" width="100&#37;">
    	<tr>
    		<td width="100%" align="center" colspan="1">
    
    <--In here should be either the random video which is standard, or the choosed video by the user-->
    
    <object width="540" height="345"><param name="movie" value="http://www.youtube.com/v/<?echo $video;?>"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/<?echo $video;?>" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="205" height="150"></embed></object><br><b>Playing video nr. <? echo $zahl; ?> of <? echo $anzahl; ?></b>
        </td>
      </tr>
      <tr>
      	
      	<td width="50%" align="center">Choose a video            
         <FORM name="drop_list" method="POST" >
    
        <SELECT NAME="Vide">
        <Option value="" >Video Liste</option>
    <--In here should be the generated Options out of the arrayfile-->
        </SELECT>
        </form>
         
      	</td>
      </tr>
    </table>
    Sry for my bad english i am from germany
    Last edited by Exking; 01-06-2010 at 06:26 AM.

  2. #2
    Join Date
    Jan 2010
    Posts
    5
    OK so it seems that this topic is not clearly enough i wanna formulate my question a bit different now.

    Thats my generated Dropdown out of a array.
    Code:
    <?
        	echo '<select name="myselect" onChange="vidchange()">';
    
    for($i = 0; $i < count($zahl_array); $i++)
    {
    echo '<option value="'.$i.'">'.$zahl_array[$i].'</option>';
    }
    
    echo '</select>';
    ?>
    I need the function vidchange. That should get the choosed value. Then it should formulate a link like this.
    Code:
    <object width="540" height="345"><param name="movie" value="http://www.youtube.com/v/----VALUE----"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/----VALUE----" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="205" height="150"></embed></object>
    The value that is given to the function corresponds to a link-fragment in array.

    I hope someone can help me.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles