javascript - Populate form fields with selected value of previously selected form fields -


i doing holiday booking form using rs form joomla whereby want answers previous questions automatically populate answer other questions that, example, answer 'what airline person 1 travelling on?' automatically populates answer 'what airline person 2 travelling on?'.

i able simple text fields when check box (id=samedetails20 in code below) checked. when checked, following works:

<script type="text/javascript">  function repeat(f) {   if(f.samedetails20.checked == true) {  f.airline2.value = f.airline1.value; f.airport2.value = f.airport1.value; f.flightno2.value = f.flightno1.value; f.airlinereturn2.value = f.airlinereturn1.value;   } }  </script> 

html

<input type="text" value="" size="20" name="form[airline2]" id="airline2" class="rsform-input-box">` 

however, form includes drop down list select arrival/departure times , pop calendar arrival/departure dates. not know how values these automatically populate other fields.

i have tried use selectedindex , options not work or doing wrong e.g.

f.departuretime2.value = f.departuretime1.options[f.departuretime1.selectedindex].value; 

sample html

<select name="form[departuretime2][]" id="departuretime2" class="rsform-select-box"><option value="00">00</option><option value="01">01</option> <option value="02">02</option><option value="03">03</option>  

etc.

i have no idea how pop-up calendar:

sample html:

<input id="txtcal9_1" name="form[dateofdeparture1]" type="text" class="txtcal rsform-calendar-box" value="departure date"> (departure date default value until date selected) 

any appreciated.

javascript client-side only. no values sent server, , js must work it's got on client machine (that is, it's received server).

this means when new page sent after page reload (like refresh or form submit or new window), javascript sent fresh values. old ones gone, unless browser ( = client side) remembers typed in <input> box reason.

so, no, can't in javascript. you'll need server-side php or asp or jsp receive values server-side, process them, , send them client javascript use.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -