ajax

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<script src="/lib/php/JsHttpRequest/JsHttpRequest.js"></script>
<script language="JavaScript">
function doLoad() {
//alert(value);
// Create new JsHttpRequest object.
var req = new JsHttpRequest();
// Code automatically called on load finishing.
req.onreadystatechange = function() {
if (req.readyState == 4) {
// Write result to page element (_RESULT become responseJS).
document.getElementById('result').innerHTML = req.responseJS.str;
// Write debug information too (output become responseText).
document.getElementById('debug').innerHTML = req.responseText;
}
}
// Prepare request object (automatically choose GET or POST).
req.open(null, 'ajax.php', true);
// Send data to backend.
req.send( {
country_id: document.getElementById("mycountry_id").value,
//mod: document.getElementById("mymod").value,
mydo: 'city_list'
}
);
}
</script>
<!-- кусок формы 1 -->
<tr class="grid">
<td class="head">Страна</td>
<td>
<select name="form[country_id]" id="mycountry_id" onchange="doLoad()">
{html_options options=$form.country_tree selected=$form.country_id}
</select>
</td>
</tr>
<tr class="grid">
<td class="head">Город</td>
<td>
<span id="result">
<select name="form[city_id]" id="result__">
{html_options options=$form.city_tree selected=$form.city_id}
</select>
</span>
<input type="hidden" name="form[city_id_old]" value="{$form.city_id}" id="city_old">
<span id="result_" style="border:0px solid #000; padding:2px"></span>
<span id="debug" style="border:0px dashed red; padding:2px"></span>
</td>
</tr>
<!-- кусок формы 2 -->
<tr class="grid">
<td class="head">Тип доставки</td>
<td>{html_options name="form[delivery_id]" options=$form.delivery_tree selected=$form.delivery_id}</td>
</td>
<tr class="grid">
<td class="head">Цена доставки</td>
<td><input type="text" name="form[price_delivery]" value="{$form.price_delivery}" style="width:20%"></td>
</tr>