php - How to get value of input field from a form in a script -


i trying display value form in script using console.log() troubleshooting purposes seems not working. here script. there missing?

jquery(document).ready(function() {      var user = jquery('#id').val;     var file = jquery('#custom-file-input').val;     console.log(file); }); 
echo "<form method='post' enctype='multipart/form-data' id='test_ajax'>"; echo "<select name='id' id='form-option' class='test-only'>"; echo '<option selected="selected">' .'choose user'. '</option>';  foreach ($registeredusers $key => $value) {     $registered = jfactory::getuser($value);     echo '<option value="'.$registered->id.'">'.$registered->name.'</option>';a } echo "</select>";  echo "<input name='uploadedfile' type='file' id='custom-file-input' class='test-only' /> <br/>"; echo '<input type="submit" name="submit" value="upload" id="custom-submit-input">'; echo "</form>"; 

use val() value of element.

var user = jquery('#id').val 

should be

var user = jquery('#form-option').val(); 
  1. notice () of val
  2. the id of element form-option, id name of dropdown.

Comments