This is actually very simple to do. Just change two =linesin the JavaScript
$('#country').chainSelect('#state','/examples/jquerycombo/combobox.php',
$('#state').chainSelect('#city','/examples/jquerycombo/combobox.php',
Change the path and the file combobox.php to a .tpl page =on yourserver. Here is a template for you to use below. Just use a new case =statementfor each new country/list of cities and follow the pattern. Don’t =forgetyou still need two more JavaScript files that need to be linked in your =page.The author includes them in his zip file.
Good luck!
[function name=3Drun]
-- code for country
[showif [_id]=3Dcountry]
[switch =value=3D[_value]]
[case =value=3D3]
[return][{"1":"NewYork"},{"2":"Montana"},{"3":"Texa=s"},{"4":"Hawaii"}][/return]
[/case]
[default]
[return][["Nostate"]][/case]
[/default]
[/switch]
[/showif]
-- code for state
[showif [_id]=3Dstate]
[switch =value=3D[_value]]
[case =value=3D4]
[return][{"1"=:"Honolulu"},{"2":"Hilo"},{"3":&q=uot;Lahaina"},{"4":"Kona"}][/return]
[/case]
[default]
[return][["Nocity"]][/case]
[/default]
[/switch]
[/showif]
[return][/return]
[/function][run]
From: Lawrence[mailto:lawrence@authorsimage.com]
Sent: Tuesday, January 26, 2010 1:17 AM
To: talk@webdna.us
Subject: [WebDNA] PHP Array translated to =Webdna
Hi,
Can anyone help me with this.
I have found a JQuery script that would save me a lot of time,(http://www.codeassembly.com/Simple-chained-combobox-plugin-for-jQu=ery/)but it is linked to a PHP file.
I'm trying to create my own TPL file.
If there is a PHP Guru who could help me understand how to convert thefollowing code to some nice Webdna...
I have started with something looking like the following, but I'm not =sure I'mgoing the right direction.
[searchdb=3D../admin/clubs.db&neLIGUEdata=3DFINDALL®IONsumm=3Dt]
[arrayset name=3Dregion&dim=3D2,[numfound]]
[founditems]([SKU])=3D[region]
[/founditems][/arrayset]
[/search]
Thanks in advance
Lawrence
<?php
$array =3D array();
if ($_GET['_name'] =3D=3D 'country')
{
=if ($_GET['_value'] =3D=3D 3 )//usa
={
&=nbsp; $array[] =3D array('1' =3D> 'Montana');
&=nbsp; $array[] =3D array('2' =3D> 'New York');
&=nbsp; $array[] =3D array('3' =3D> 'Texas'); =
&=nbsp;} else
&=nbsp;{
&=nbsp; $array[] =3D array('0' =3D> 'No state');
&=nbsp;}
} elseif ($_GET['_name'] =3D=3D 'state')
{
=if ($_GET['_value'] =3D=3D 2 )//New York
={
&=nbsp; $array[] =3D array('1' =3D> 'New York');
&=nbsp; $array[] =3D array('2' =3D> 'Another =city');
&=nbsp;} else
&=nbsp;{
&=nbsp; $array[] =3D array('0' =3D> 'No city');
}
} else
{
=$array[] =3Darray('1' =3D> 'Data 1');
=$array[] =3Darray('2' =3D> 'Data 2');
=$array[] =3Darray('3' =3D> 'Data 3');
}
echo json_encode( $array );
?>
|
This is actually very simple to do. Just change two =linesin the JavaScript
$('#country').chainSelect('#state','/examples/jquerycombo/combobox.php',
$('#state').chainSelect('#city','/examples/jquerycombo/combobox.php',
Change the path and the file combobox.php to a .tpl page =on yourserver. Here is a template for you to use below. Just use a new case =statementfor each new country/list of cities and follow the pattern. Don’t =forgetyou still need two more JavaScript files that need to be linked in your =page.The author includes them in his zip file.
Good luck!
[function name=3Drun]
-- code for country
[showif [_id]=3Dcountry]
[switch =value=3D[_value]]
[case =value=3D3]
[return][{"1":"NewYork"},{"2":"Montana"},{"3":"Texa=s"},{"4":"Hawaii"}][/return]
[/case]
[default]
[return][["Nostate"]][/case]
[/default]
[/switch]
[/showif]
-- code for state
[showif [_id]=3Dstate]
[switch =value=3D[_value]]
[case =value=3D4]
[return][{"1"=:"Honolulu"},{"2":"Hilo"},{"3":&q=uot;Lahaina"},{"4":"Kona"}][/return]
[/case]
[default]
[return][["Nocity"]][/case]
[/default]
[/switch]
[/showif]
[return][/return]
[/function][run]
From: Lawrence[mailto:lawrence@authorsimage.com]
Sent: Tuesday, January 26, 2010 1:17 AM
To: talk@webdna.us
Subject: [WebDNA] PHP Array translated to =Webdna
Hi,
Can anyone help me with this.
I have found a JQuery script that would save me a lot of time,(http://www.codeassembly.com/Simple-chained-combobox-plugin-for-jQu=ery/)but it is linked to a PHP file.
I'm trying to create my own TPL file.
If there is a PHP Guru who could help me understand how to convert thefollowing code to some nice Webdna...
I have started with something looking like the following, but I'm not =sure I'mgoing the right direction.
[searchdb=3D../admin/clubs.db&neLIGUEdata=3DFINDALL®IONsumm=3Dt]
[arrayset name=3Dregion&dim=3D2,[numfound]]
[founditems]([SKU])=3D[region]
[/founditems][/arrayset]
[/search]
Thanks in advance
Lawrence
<?php
$array =3D array();
if ($_GET['_name'] =3D=3D 'country')
{
=if ($_GET['_value'] =3D=3D 3 )//usa
={
&=nbsp; $array[] =3D array('1' =3D> 'Montana');
&=nbsp; $array[] =3D array('2' =3D> 'New York');
&=nbsp; $array[] =3D array('3' =3D> 'Texas'); =
&=nbsp;} else
&=nbsp;{
&=nbsp; $array[] =3D array('0' =3D> 'No state');
&=nbsp;}
} elseif ($_GET['_name'] =3D=3D 'state')
{
=if ($_GET['_value'] =3D=3D 2 )//New York
={
&=nbsp; $array[] =3D array('1' =3D> 'New York');
&=nbsp; $array[] =3D array('2' =3D> 'Another =city');
&=nbsp;} else
&=nbsp;{
&=nbsp; $array[] =3D array('0' =3D> 'No city');
}
} else
{
=$array[] =3Darray('1' =3D> 'Data 1');
=$array[] =3Darray('2' =3D> 'Data 2');
=$array[] =3Darray('3' =3D> 'Data 3');
}
echo json_encode( $array );
?>
DOWNLOAD WEBDNA NOW!
The WebDNA community talk-list is the best place to get some help: several hundred extremely proficient programmers with an excellent knowledge of WebDNA and an excellent spirit will deliver all the tips and tricks you can imagine...