Reputation: 155
My code:
<strong>Station Name</strong>
<!--This part combobox with HTML5 -->
<input type=text list=Stations>
<datalist id=Stations>
<option>Station1</option>
<option>Station2</option>
<option>Station3</option>
<option>Station4</option>
</datalist>
<div>
<strong>Number of Passanger</strong>
</div>
I want to auto submit when a station is selected and return some data (the data can be a random number) to the Number of Passengers
. How can I do that with javascript? Is PHP needed?
Thank you any help will be appreciated.
Upvotes: 0
Views: 2241
Reputation: 1060
Create a hidden submit type button(i.e. display:none;), after page load through jquery click on it automatically(i.e. $('#submit').click() ), Create a function for clicking on submit button, call it after page loads...
EDIT: HTML:
<form ...>
...
<input type="submit" id="submit" style="display:none;" />
</form>
Javascript:
function submit_click(){
$("#submit").click();
}
Now, when your auto form populating data's function called, call this function in last line submit_click();
Upvotes: 0
Reputation: 291
<datalist onchange="this.form.submit()">
This will automatically send the form
Upvotes: 1