I've found a couple of posts that do parts of what i need to achieve but I can't quite connect the dots to make it work so I'm hoping you can help.
I want to dynamically change the src url of an iframe within a page based on the user inputs within a form on a previous page i.e. I have a search widget within the sidebar of my wordpress pages and I want the values from the form to append to a base url in the iframe src.
So my form code looks like this:
<div class="book" id="book">
<form name="bookForm" action="/book-a-room/" >
<input type="hidden" name="chainAction" value="newAvailabilitySearch"/>
<span id="arrError"></span>
<input id="arrival" name="arrival" type="text" class="text-input" value="Arrival date" />
<span id="depError"></span>
<input id="departure" name="departure" type="text" class="text-input" value="Departure date" />
<select name="numberOfPersons" class="selectBox">
<option value="1">1 adult</option>
<option value="2">2 adults</option>
<option value="3">3 adults</option>
</select>
<select name="numberOfChildren" class="selectBox">
<option value="0">No Children</option>
<option value="1">1 child</option>
<option value="2">2 children</option>
<option value="3">3 children</option>
</select>
<input type="submit" class="submit" value="SEARCH RATES"/>
</form>
</div>
and the script in the header of the pages which just works the datepicker:
$(document).ready(function() {
$("#arrival").datepicker({ minDate: "0", dateFormat: "dd/mm/yy"});
$("#departure").datepicker({ minDate: "+1", dateFormat: "dd/mm/yy"});
$("#numberOfPersons").selectBox();
$("#numberOfChildren").selectBox();
$("input[type=submit]").click(function() {
$arrivalDate = $("#arrival").datepicker("getDate");
$departureDate = $("#departure").datepicker("getDate");
$("#arrError").text( $arrivalDate != null ? '':'*');
$("#depError").text( $departureDate != null ? '':'*');
return ($arrivalDate != null) && ($departureDate != null) &&
($arrivalDate.getTime() < $departureDate.getTime());
});
});
so this results in the correct variable being passed in the url to the /book-a-room/ page e.g.:
http://domain.com/book-a-room/?chainAction=newAvailabilitySearch&arrival=29%2F10%2F2013&departure=3&numberOfPersons=2&numberOfChildren=0
What i want to achieve is for the src url of the iframe in /book-a-room/ to have a set base URL e.g. mydomain.com and then have the form outputs appended as per the main page so:
<div><iframe src="https://mydomain.com&request_locale=en&arrival=29%2F10%2F2013&departure=3&numberOfPersons=2&numberOfChildren=0" class="noScrolling" scrolling-x="no"></iframe></div>
What I'd like help with is what script to add to /book-a-room/ and then what to change the html iframe code to so it pulls in the variable.
Thank you so much in advance :0)
http://domain.com/book-a-room/?chainAction=newAvailabilitySearch&arrival=29%2F10%2F2013&departure=3&numberOfPersons=2&numberOfChildren=0asiframe's src?