Hi all,

I'm trying to change some code here. It involves Smarty Templates...
I believe (actually, I hope) my problem is stemming from the javascript on the page.

Code for Location 1:

HTML Code:
<p>
<label for="fullname">
Location Type<span class="required">*</span>:</label>
<select name="location1type" onChange="redirect(this.options.selectedIndex)">
<option value="hotel" {if $data.location1type eq "hotel"}selected{/if}>Hotel</option>
<option value="location" {if $data.location1type eq "location"}selected{/if}>Location</option>
</select>
</p>

<p>
<label for="fullname">
Location 1<span class="required">*</span>:</label>
<select name="location1">
{if $data.location1type 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.location1}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.location1}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.location1

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>
Code for Location 2:
HTML 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>
These are on the same page. I want to be able to change Location 1 based on the Location 1 Type selected. However, when I change Location 1 Type, it changes my Location 2 options instead of Location 1. I've changed the names, as much as I can tell, to match form names/elements but it's not done any good.

Thanks for any help!