I have used an Input type="date" field for accepting date value from the user in my application. But I have to post value of date named as "sdate" into the address used in the action method as shown below. I want to post value of Input type date field into action of Form Post method.
I have stored those values via AJAX into variables but How to use those AJAX variables into the action of
My written view code is as below:
<form method="post" id="report" class="live" target="_blank" action="http://wcidevapps.com/salescentral/jm2/troute.php?custnum=<?php echo $KUNNR?>&staffid='+staffid+'&rdate='+sdate+'">
<fieldset><legend>Today's Tasks</legend></fieldset>
<div class="span5 well">
<div class="form-inline">
<label class="control-label"><b> For </b> </label>
<input type="text" name="stech" id="stech"/>
</div><br/><br/>
<div class="form-inline">
<label class="control-label"><b> On </b> </label>
<input type="date" class="datefield" name="sdate" id="sdate"/>
</div><br/><br/>
<button type="submit" name="open" class="btn btn-primary offset4"><i class="icon-file"></i> Open</button>
</div>
</form>
<script type="text/javascript">
var onFilter = function () {
var obj = {
sdate: $("#sdate").val(),
stech: $("#stech").val()
};
$.ajax({
method: 'POST',
dataType: "JSON",
contentType: "application/json; charset=utf-8",
url: root + 'standard_projects/?json',
data: obj,
success: function (d) {
sdate=d.sdate,
staffid=d.staffid
}
});
}
$("#sdate").live("change", onFilter);
$("#stech").live("change",onFilter);
</script>
How can I use those AJAX variables ? sdate & staffid
sdate&staffiddefined outside the function?var sdate, staffid;