mercredi 15 avril 2015

Get form values to create a custom URL

I have the following form:



<form>
<div>Adults</div>
<div>
<select name="adults">
<option selected="selected" value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
</div>
</div>
<div>
<div>Children</div>
<div>
<select name="children">
<option selected="selected" value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
</div>
</div>
<div>
<div>Check-in date</div>
<div>
<input name="date_from" value="16-04-2015" type="text"></div>
</div>
<div>
<div>Check-out date</div>
<div><input name="date_to" value="17-04-2015" type="text"></div>
</div>
<div>
<input value="Check Availability" type="submit">
</div>
</form>


Now I want to call a javascript function on above form submit. This function will get all form elements values and create the following URL to redirect.



online-reservation.html#!/Rooms/date_from:16-04-2015/date_to:17-04-2015/adults:1/children:0


How can I create this JS function?


Thanks.


Aucun commentaire:

Enregistrer un commentaire