I have 2 chained list :
<select>
<option> Half Life </option>
<option> Mario </option>
...
</select>
<select>
<option> Gordon </option>
<option> Alexia </option>
<option> Peach </option>
<option> Luigi </option>
...
</select>
These selects are populated by MySQL requests (ZSQL Method)
I would like to load this second form only when it's necessary. I don't know how to do in a Zope Page Template to link these select dynamically (Certainly with AJAX and JAVASCRIPT?). So I search in some topics but I don't find examples..
(I find these topics, but I don't know how to operate : dynamicly fill table using zpt and ajax as update; http://play.pixelblaster.ro/blog/topics/AJAX ; http://zajax.net/)
Thanks in advance !
1) in the form page:
$("#first_select").click(function(){
var dat_game = $('#first_select option:selected').text();
$.post("a_new_page_template", { dat_game: dat_game},
function(data){
var $response=$(data);
var res = $response.filter('#whatiwant').html();
$('#second_select').append(res);
});
return false;
});
2) in the 'a_new_page_template':
<html>
<body tal:define="results here/sql_select_value;
start request/start|python:0;
batch python:modules['ZTUtils'].Batch(results,
size=50,
start=start)">
<span id="whatiwant">
<tal:x repeat="result batch">
<option><tal:x replace="result/value">value goes here</tal:x></option>
</tal:x>
</span>
</body>
</html>
Thanks to me :)