-1

I am using the jQuery uploader to upload images to my website, it also adds the name of the photo to the MySQL database. The photo name is being added just fine, and I have had a go at adapting some code to add a field called equipmentID to the database too, but instead of pulling the info from the equipmentID field I just get $equipmentID submitted to the database field instead.

<script type="text/javascript">
    $('#fileupload').fileupload({
        formData: { equipmentID: '$equipmentID' }
    });
</script>

Could anyone tell me, or point me in the right direction on how I can pull the contents of the equipmentID field from my upload form and replace the submitted '$equipmentID' with the actual value of the text field?. What I expected to happen was the contents of the equipmentID field to replace $equipmentID, instead of just the words $equipmentID being posted to the db.

Sorry for the vagueness, im used to PHP, so im not q'd up on jquery at all.

Iain Simpson
  • 8,011
  • 13
  • 47
  • 66

2 Answers2

0

'$equipmentID' as you have it, is a string literal. If you want to get the value of a form field it would be something like this:

$('#equipmentID').val()
Hippocrates
  • 2,510
  • 1
  • 19
  • 35
0

I solved it myself in the end using

<script type="text/javascript">
$('#fileupload').bind('fileuploadsubmit', function (e, data) {

    var input = $('#equipmentID');
   data.formData = {equipmentID: input.val()};
   if (!data.formData.equipmentID) {
     input.focus();
     return false;
   }
 });
  </script>
Iain Simpson
  • 8,011
  • 13
  • 47
  • 66