user1281426
user1281426

Reputation: 27

dynamic links / dropdown menu

I have a drop down box that dynamically creates the option items by running a sql query. However, I also want these options to link to a page where the anchor is also the value of the option. i.e. mysite.com/date.php#april if April is clicked on. As you can see, I have the anchor # in there, but I cant figure out how to add the dynamic variable ($startdate).

This is my first post; let me know if additional info is required.

echo '<select onChange="location=(this.value)";>';
echo '<option value="date.php#">';
echo date('F Y', mktime(0, 0, 0, $startdate[1], $startdate[2], $startdate[0]));
echo '</option>';

Upvotes: 0

Views: 311

Answers (1)

Rob
Rob

Reputation: 12872

<?php
$date = date('F Y', mktime(0, 0, 0, $startdate[1], $startdate[2], $startdate[0]));
echo '<select onChange="location=(this.value)";>';
echo '<option value="date.php#' . $date . '">' . $date . '</option>';

Upvotes: 2

Related Questions