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
'scriptData'	: {
          "success_action_status"		: "201",
          "userID"                                : "<?= $userID ?>",
	  "albumID"                             : $('#albumID').val()						

Open in new window

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>";

Open in new window

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>
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

1. View the source and search for "albumID" to check to make sure there's no other <input> with that same ID.

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...?
>  echo "<option value=".$row['id'].">$row[albumName]</option>";

do you probably want:

    echo "<option value=".$row['id'].">".$row['albumName']."</option>";
UltraFluxAuthor Commented:
Hi gr8gonzo and ahoffann,

$('#albumID option:selected').val()
Still saved id = 4

Not sure what to do still stuck...
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

what about my "echo ... " suggestion?
UltraFluxAuthor Commented:
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>";

Open in new window

please read my suggestion ID: 37729064 again
please make yourself used to the change I suggested, and test it
UltraFluxAuthor Commented:
I did test it as I said above. Nothing changed, still saves id=4
Oh I see what's happening. The scriptData is evaluating at the time that the page loads, so it's setting itself to 4 at the beginning of the page load when uploadify is setting up, but when the <select> option changes, you are not sending the updated value back to scriptData, so it stays on the original value at page load.

You'll need to do something like this:

Change: <select name='albumID' id='albumID'>
To: <select name='albumID' id='albumID' onChange="updateScriptData();">

Then add this Javascript function:

function updateScriptData()
  // Pull existing settings
  scriptData = $('#file_upload').uploadifySettings('scriptData');

  // Update the album ID to the <select>ed option
  scriptData.albumID = $('#albumID').val();

  // Update the settings


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
UltraFluxAuthor Commented:
UltraFluxAuthor Commented:
Thanks a lot  gr8gonzo!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.