Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Dropdown value?
  • Hi, i´m trying to get the script do take a value from a dropdown list togheter with the uploadfiles but having some problems.

    This is my code:


    <script type=\"text/javascript\">
    function startUpload(id, conditional)
    {
    if(conditional.value.length != 0) {
    $('#'+id).fileUploadStart();
    } else
    alert(\"Du måste välja ett album till bilderna\");
    }
    </script>
    <script type=\"text/javascript\">

    $(document).ready(function() {
    $(\"#fileUpload\").fileUpload({
    'uploader': 'extra/uploader.swf',
    'cancelImg': 'extra/images/cancel.png',
    'script': 'extra/upload.php',
    'sizeLimit': '2000000',
    'fileDesc': 'Image Files',
    'fileExt': '*.jpg;*.jpeg;*.gif;*.png',
    'multi': true,
    'auto': false,
    'buttonText' : 'Select files',
    'displayData': 'percentage'
    });

    $('#albumid').bind('change', function(){
    $('#fileUpload').fileUploadSettings('scriptData','&amp;amp;albumid='+$(this).val());
    });

    });

    </script>



    <select name=\"albumid\" id=\"albumid\">
    <option value=\"\"></option>
    <?
    $getgallery=\"SELECT * FROM galleri_namn ORDER BY id ASC\";
    $gallerydata=mysql_query($getgallery) or die(mysql_error());

    while($rad = mysql_fetch_array($gallerydata))
    {
    ?>
    <option value=\"<?=$rad[id];?>\"><?=$rad[namn];?></option>

    <? } ?>
    </select>
    <br/>

    <div id=\"fileUpload\">You have a problem with your javascript</div>
    <br/>
    <a href=\"javascript:startUpload('fileUpload', document.getElementById('albumid'))\">Starta uppladdning</a> | <a href=\"javascript:$('#fileUpload').fileUploadClearQueue()\">Rensa kö</a>



    The files is uploaded with no problem, but i cant get the option value to be posted.
    The code in my upload.php is:

    $gid=$_POST['albumid'];


    BUT if I change from a dropdownlist to a input field like this:
    <input name=\"albumid\" id=\"albumid\" type=\"text\" maxlength=\"255\" size=\"50\" />

    it works.

    How come it not working with the dropdown list?

    Reguards
  • There could be a couple of things.

    1. the bind function should be outside the .fileUpload() but still in the .ready()
    2. '&amp;albumid=' should be '&albumid='
    3. uploadify currently only uses GET not POST
    4. Check your option list is populating correctly. You may be seeing the name in the list, but is the value correct?