Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Programming/Scripts

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 6th January 2010, 00:28
Exking Exking is offline
Junior Member
 
Join Date: Jan 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Dropdown reading array and onclick

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.

thats what i got so far and it works.
Code:
<?
  		echo '<SELECT name=bild>';
  		        
              foreach ($zahl_array as $key => $value)
              {
                echo '<OPTION value='.$value.'> '.$value.'';
              }
      echo '</select>'; 
      ?>
$zahl_array is reading the array content out of a .txt file.

Now the problem is that i want something to happen when you change/click on one link in the dropdown.

Above this code, there is a table with an randomly generated Image.
Code:
$zahl_array = file('zahl.txt');
$num = rand(0, count($zahl_array) - 1);
$zahl = $zahl_array[$num];

//In here <--> should be the if-clause.
//1. possiblity. Nothing is choosed so it stays random like this
...html...<img src="/images/<? echo $zahl; ?>.jpg">...html...
//2.possibility. A link is choosed out of the dropdown.
...html...<img src="/images/<? echo $choosed_zahl; ?>.jpg">...html...
Now if the user chooses one link in the dropdown it should change the Image above to the one that the user choosed.

Sry for my bad english i am from germany
Reply With Quote
Sponsored Links
  #2  
Old 6th January 2010, 13:37
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lneburg, Germany
Posts: 41,711
Thanks: 1,900
Thanked 2,703 Times in 2,546 Posts
 
Default

I think you have to use AJAX to do this. Here's a very good library that might help you to accomplish this: http://jquery.com/
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 03:29.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.