Reputation: 51
I am trying to set this up so that when a user changes the 'hier_start', the page is refreshed and the dropdown is preselected with the selection that was just made.
<form name='categories' id="categories">
<div class="row">
<select name="hier_start" onchange="javascript: NextCat('A', this.value)">
<option value="0" parent="0">Select...</option>
[% FOREACH hier_start IN categories.keys %]
<option value="[% hier_start %]">[% hier_start %]</option>
[% END %]
</select>
<select name="hier_A" style="display:none" onchange="javascript: NextCat('B', this.value)">
<option value="0" parent="0">Select...</option>
</select>
<select name="hier_B" style="display:none" onchange="javascript: NextCat('C', this.value)">
<option value="0" parent="0">Select...</option>
</select>
<select name="hier_C" style="display:none" onchange="javascript: NextCat('D', this.value)">
<option value="0" parent="0">Select...</option>
</select>
<select name="hier_D" style="display:none">
<option value="0" parent="0">Select...</option>
</select>
</div>
Upvotes: 0
Views: 1907
Reputation: 13
You need to use a server side language (PHP, ASP, etc) or cookies to send the values. There might be a way of doing it by replacing the html without refreshing the page (which I don't recommend) but this disappears when the page is reloaded again since it loads the original .html file.
Upvotes: 0
Reputation: 2185
The onchange attribute should only contain the action to perform:
<select name="hier_start" onchange="javascript: NextCat('A', this.value)">
should be
<select name="hier_start" onchange="NextCat('A', this.value)">
I don't see any details as to your approach for refreshing the page, so I cannot provide any insight on that other than you probably don't need to refresh the page at all.
Upvotes: 2