UltraFlux
asked on
js help with uploadify scriptdata
How can I get the correct value from a dropdown. I can only get the first one in the list. In this case no matter what i select I get albumID=4 as it is the first in the list.
Code from Uploadify
Code from Dynamic Dropdown
Static view of Dropdown
<select name="albumID" id="albumID">
<option value="4">Game Images</option>
<option value="3">Game Videos</option>
<option value="5">Personal</option >
</select>
Code from Uploadify
'scriptData' : {
"success_action_status" : "201",
"userID" : "<?= $userID ?>",
"albumID" : $('#albumID').val()
},
Code from Dynamic Dropdown
echo "Select an album.<br/>";
echo "<select name='albumID' id='albumID'>";
while($row = mysql_fetch_array($result)){
echo "<option value=".$row['id'].">$row[albumName]</option>";
}
echo "</select>";
Static view of Dropdown
<select name="albumID" id="albumID">
<option value="4">Game Images</option>
<option value="3">Game Videos</option>
<option value="5">Personal</option
</select>
> echo "<option value=".$row['id'].">$row[ albumName] </option>" ;
do you probably want:
echo "<option value=".$row['id'].">".$ro w['albumNa me']."</op tion>";
do you probably want:
echo "<option value=".$row['id'].">".$ro
ASKER
Hi gr8gonzo and ahoffann,
Tried
$('#albumID option:selected').val()
Still saved id = 4
Not sure what to do still stuck...
Tried
$('#albumID option:selected').val()
Still saved id = 4
Not sure what to do still stuck...
what about my "echo ... " suggestion?
ASKER
same, no improvement
if($numalbums > 0){
echo 'Select an album.<br/>';
echo "<select name='albumID' id='albumID' width='200px'>";
while($row = mysql_fetch_array($result)){
echo "<option value=".$row['id'].">$row[albumName]</option>";
}
echo "</select>";
}
please read my suggestion ID: 37729064 again
please make yourself used to the change I suggested, and test it
please make yourself used to the change I suggested, and test it
ASKER
I did test it as I said above. Nothing changed, still saves id=4
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
WORKS!
ASKER
Thanks a lot gr8gonzo!
2. Try:
$('#albumID option:selected').val()
It should be the same thing, but it's a little more defined.
3. If you still get ID=4 after trying #2, then it could be an issue with the timing / order-of-events (e.g. the code is running while the dropdown value has not yet changed to its real value). I'm not sure when the code is running...?