Getting URL value into clone select box
I have a form where i'm asking room details and how many children. Then if it is >0 how old are they.
When the form is sent to show the list of rooms I want the values selected to be in the select box with what is selected but it is displaying the default 1.
How do I get the URL parameter to put the selected value from the returned URL into the cloned select boxes?
Thanks
- age1 = getUrlParameter('age1');
- age2 = getUrlParameter('age2');
- age3 = getUrlParameter('age3');
-
-
- $('#numberOfChildren').change(function(){
-
- $('#ach-age').html('');
- var $div = $('#add_select'), //Select the appending div
- $select = $('<select/>', {name : 'childAges', class: 'form-control ach-c-age'}), //Create a template
- index = $(this).val(); //get the number of select
-
-
-
- $div.empty(); //Erase old select
-
- if(!index) return; //Stop the code if the number of child is 0
-
- for(var i=1; i<14; i++){ //Maximum child age
- var $option = $('<option/>', {text : i, value : i});//Create the option element
- $select.append($option);//Append to the template
- $('#ach-age').html('Child age/s');
- }
-
- for(var u=0; u<index; u++){//Get the number of child
- var $clone = $select.clone(); //Clone the template
- $clone.attr('name', 'age'+(u+1)).appendTo($div); //Change its id and append to the container
- }
- }).trigger('change');