Howdy, Stranger!

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

Values from select
  • Hey,

    I am having literally a brain storm as I am unable to resolve my issue.

    I have a classical select box, e.g.:

    <select name=\"gal\" id=\"frm-gal\">
    <option value=\"1\">1</option>
    <option value=\"2\">2</option>
    <option value=\"3\">3</option>
    </select>


    and i need to pass the values threw scriptData and here is the problem.

    'scriptData': {'PHPSESSID': '<?php echo session_id();?>', 'id_menu': THEISSUE},


    I can pass the value by using the uploadifySettings method and change(), e.g.

    $(\"#frm-gal\").change(function() {
    var idGal = $(\"#frm-gal option:selected\").val();
    #(‘#frm-file’).uploadifySettings('scriptData', {'PHPSESSID': '<?php echo session_id();?>', 'id_menu': idGal});

    });


    Nevertheless, the problem is when the user doesn't select an option and just leaves the Option 1 and doesn't trigger the change function. How to pass the value from the first option if there is no action??


    Thanks for you advices!
  • The obvious answer would be just to do

    'scriptData': {'PHPSESSID': '<?php echo session_id();?>', 'id_menu': '1'},


    but for transportable code add the 'selected' statement to your html option

    select name=\"gal\" id=\"frm-gal\">
    <option value=\"1\" SELECTED>1</option>
    <option value=\"2\">2</option>
    <option value=\"3\">3</option>
    </select>


    and then in uploadify
    'scriptData': {'PHPSESSID': '<?php echo session_id();?>', 'id_menu': $('#frm-gal').val()},


    if you don't add 'SELECTED' to your html then $('#id').val() will find NULL. You may not know this but, when the html renders a html select list i doesn't actually have the first item selected, although it is the one visible. Always add 'SELECTED' to the option you want as the default even when not using uploadify.
  • Thank you, I don't know what I was doing wrong but now it is ok.