| 1 | <script type="text/javascript"> |
|---|
| 2 | {assign var=counter value=0} |
|---|
| 3 | {foreach from=$optionDependencies item=dep} |
|---|
| 4 | {assign var=counter value=$counter+1} |
|---|
| 5 | document.getElementById('{$dep.srcOption}').style.borderStyle = 'dashed'; |
|---|
| 6 | |
|---|
| 7 | function callback{$counter}() { |
|---|
| 8 | {if $dep.dstType == "select"} |
|---|
| 9 | var val = document.getElementById('{$dep.srcOption}').value; |
|---|
| 10 | var ajaxRequest = new AjaxRequest(); |
|---|
| 11 | ajaxRequest.openPost('{$dep.optionDependencyRequest}'+SID_ARG_2ND, 'query='+encodeURIComponent(val), function() { |
|---|
| 12 | if(ajaxRequest.xmlHttpRequest.readyState == 4 && ajaxRequest.xmlHttpRequest.status == 200) { |
|---|
| 13 | |
|---|
| 14 | var dest = document.getElementById('{$dep.dstOption}'); |
|---|
| 15 | for(var i=dest.length; i>=0; i--) { |
|---|
| 16 | dest.options[i] = null; |
|---|
| 17 | } |
|---|
| 18 | |
|---|
| 19 | var response = ajaxRequest.xmlHttpRequest.responseXML.getElementsByTagName('row'); |
|---|
| 20 | for(var i=0; i<response.length; i++) { |
|---|
| 21 | document.getElementById('{$dep.dstOption}').options[i] = new Option(response[i].firstChild.nodeValue, response[i].getAttribute("optionID"), false, response[i].getAttribute("optionID") == '{$dep.dstValue}'); |
|---|
| 22 | } |
|---|
| 23 | } |
|---|
| 24 | }); |
|---|
| 25 | |
|---|
| 26 | {else if $dep.srcType == 'input'} |
|---|
| 27 | var response = ajaxRequest.xmlHttpRequest.responseXML.getElementsByTagName('row')[0]; |
|---|
| 28 | document.getElementById('{$dep.dstOption}').value = response[0].firstChild.nodeValue; |
|---|
| 29 | {/if} |
|---|
| 30 | } |
|---|
| 31 | |
|---|
| 32 | {if $dep.srcType == 'select'} |
|---|
| 33 | document.getElementById('{$dep.srcOption}').onchange = callback{$counter}; |
|---|
| 34 | onloadEvents.push(function() { |
|---|
| 35 | callback{$counter}(); |
|---|
| 36 | }); |
|---|
| 37 | {else if $dep.srcType == 'input'} |
|---|
| 38 | document.getElementById('{$dep.srcOption}').onkeyup = callback{$counter}; |
|---|
| 39 | {/if} |
|---|
| 40 | {/foreach} |
|---|
| 41 | </script> |
|---|