tags:

views:

54

answers:

2

Hi, how get values from input? I have this script, but i don't now, how catch values with jquery

<script type="text/javascript">
$(document).ready(function() {
    $("#fileInput2").uploadify({
        //How get value from input (fileInput2)
    });
});
</script>
<div class="demo">
<input id="fileInput2" name="fileInput2" type="file" /> <a href="javascript:$('#fileInput2').uploadifyUpload();">Upload Files</a>
</div>

Thanks

+3  A: 
<script type="text/javascript">
    $(document).ready(function()
    {
        $("#fileInput2").uploadify(
        {
            // Get value
            var input_field_value = $(this).val()
       });
    });
</script>

<div class="demo">
    <input id="fileInput2" name="fileInput2" type="file" /> 
    <a href="javascript:$('#fileInput2').uploadifyUpload();">Upload Files</a>
</div>

EDIT

You are calling the uploadify function on fileInput2, so if you write $(this), it will refer to this same element, which is fileInput2 textbox. So writing $(this).val() will give you the value of this input element.

Night Shade
Thanks, but allways get empty values
probably your uploadify plugin isn't working properly.
Night Shade
Maybe problam is type: file?When i use type text, everything works.
@gloris: no the problem isn't there, because it works perfectly for me as type: file.
Night Shade
+1  A: 

Use the val() method:

$("#fileInput2").val();

Or:

$("#fileInput2").uploadify({
  alert($(this).val());
});
Sarfraz