I need to manipulte form fields using javascript. In the "location 2 type" area if you select either hotel or location it changes the "location 2" area respectively.
Now the trick is to do the same manipulation with the "departure and arrival dates" changing respecitvely with the field "round trip". Here is the code that I currently have. I am having trouble understanding how it works. I need some help.
Thank you
Code:<p><label for="fullname"> Location 2 type<span class="required">*</span>:</label> <select name="location2type" onChange="redirect(this.options.selectedIndex)"> <option value="hotel" {if $data.location2type eq "hotel"}selected{/if}>Hotel</option> <option value="location" {if $data.location2type eq "location"}selected{/if}>Location</option> </select></p> <p><label for="fullname"> Location 2<span class="required">*</span>:</label> <select name="location2"> {if $data.location2type eq "location"} <option value="">---------- select a location ----------</option> {section name=item loop=$locations} <option value="{$locations[item].location_code}" {if $locations[item].location_code eq $data.location2}selected{/if}>{$locations[item].location_desc}</option> {/section} {else} <option value="">---------- select a hotel ----------</option> {section name=item loop=$hotels} <option value="{$hotels[item].hotel_num}" {if $hotels[item].hotel_num eq $data.location2}selected{/if}>{$hotels[item].hotel_name}</option> {/section} {/if} </select> </p> <script language="JavaScript"> <!-- var group=new Array(2) for (i=0; i<2; i++) group[i]=new Array() group[0][0]=new Option("---------- select a hotel ----------","") {section name=item loop=$hotels} group[0][{$smarty.section.item.iteration}]=new Option("{$hotels[item].hotel_name}", "{$hotels[item].hotel_num}") {/section} group[1][0]=new Option("---------- select a location ----------","") {section name=item loop=$locations} group[1][{$smarty.section.item.iteration}]=new Option("{$locations[item].location_desc}", "{$locations[item].location_code}") {/section} var temp=document.Reservations.location2 function redirect(x){ldelim} for (m=temp.options.length-1;m>0;m--) temp.options[m]=null for (i=0;i<group[x].length;i++){ldelim} temp.options[i]=new Option(group[x][i].text,group[x][i].value) {rdelim} temp.options[0].selected=true {rdelim} //--> </script>





Bookmarks