PDA

View Full Version : dropdown list 'selected' problem


songboy
12-22-2009, 11:07 PM
I have three dynamically related dropdown lists that work fine - so that's the hard job done. Unfortunately, I seem to have a much simpler issue that I can't solve. Basically, when the first dropdown is populated, the list label is selected and appears in blue. What I need is for the chosen (clicked) list element to become selected and turned blue. By the way, I would rather that the list stayed intact with the selected option being highlighted (rather than the whole list disappearing and the selected item then appearing at the top of the list on its own).
This is the html, php and javascript I've got:

<div id="Layer4">
<?php
include("connection.php");
$query = sprintf("SELECT DISTINCT special_word FROM songs ORDER BY special_word");
$result = mysqli_query($cxn, $query)or die ("Couldn't execute query.");
?>
<form name = "choices" action = "indexa.php" method = "POST">
<div id="Layer60">
<select name="special_word" size="14"
onChange ="document.forms['choices'].submit()">
<option value ="SPECIAL LIST" selected>SPECIAL LIST<option />
<?php
while($row = mysqli_fetch_array($result))
{
extract($row);
echo"<option value ='$special_word'>$special_word";
}
?>
</select>
</div>
Four items appear in the list as there are only four in the database. When you click one, the item briefly turns blue then the originally selected label turns blue again (and the list is back to where it started). The second dropdown fires OK but the first dropdown looks as if no choice has been made.
I looked at DJs video and he does refer to this issue. He says that it is all due to the page sending to itself. He also gives a get-out. Unfortunately, his solution is not quite what I want and, even if it was, I can't figure out how to apply his idea to my script.
How can I choose one of my four items so that the list remains and the chosen item turns blue.
PS None of the list items are hard coded. They are all dragged from the database.
A solution to this issue would be a gratefully received Christmas present !
Thanks - Songboy

davidj
12-24-2009, 06:53 AM
hi there

I am on the case

Wife's present shopping must take priority though

I will code something up during the holidays

songboy
01-10-2010, 12:21 AM
Hi - my problem above has been sorted.

davidj
01-12-2010, 04:27 PM
shucks

sorry mate

was distracted