Reputation: 331
I have this javascript/ajax code that I have been tweaking for half a day now to just add a div response that was echoed by php script. Any help would be much appreciated.
<form id="form1" name="form1" method="post" enctype="multipart/form-data">
<select id="machine" name="machine" class="field" >
<option value="" selected="selected">Choose..</option>
<option value="machine1.php">Machine 1</option>
<option value="machine2.php">Machine 2</option>
</select>
</fieldset>
<fieldset>
<legend><strong>Select a file to upload</strong></legend>
<input type="file" id="files" name="files[]" size="40" multiple="multiple" />
<br />
<p></p>
<input type="submit" value="Upload File" id="upload" />
<br />
<br />
</form>
<div id="information"></div>
</fieldset>
<fieldset>
<legend><strong>Uploaded Files</strong></legend>
<div id="uploaded"></div>
</fieldset>
<script type="text/javascript">
function addaction(actionvalue){
$("#form1").attr("action",actionvalue);
};
</script>
Upvotes: 1
Views: 87
Reputation: 227
As GHOST93 said, there's no AJAX call in your code. But to me it seems like you're trying to change the action attribute based on what is selected in the select box. That by itself doesn't need an Ajax call.
Try adding something like this into your script http://jsfiddle.net/W4Km8/7431/
$("#machine").change(function(){
$("#form1").attr("action", $(this).val());
});
And you can probably drop your addaction() function.
Upvotes: 1