RE: [WebDNA] PHP Array translated to Webdna

This WebDNA talk-list message is from

2010


It keeps the original formatting.
numero = 104595
interpreted = N
texte = This is a multi-part message in MIME format. ------=_NextPart_000_0258_01CA9E5D.89509FF0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit This is actually very simple to do. Just change two lines in 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 your server. Here is a template for you to use below. Just use a new case statement for each new country/list of cities and follow the pattern. Don't forget you 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=run] -- code for country [showif [_id]=country] [switch value=[_value]] [case value=3] [return][{"1":"New York"},{"2":"Montana"},{"3":"Texas"},{"4":"Hawaii"}][/return] [/case] [default] [return][["No state"]][/case] [/default] [/switch] [/showif] -- code for state [showif [_id]=state] [switch value=[_value]] [case value=4] [return][{"1":"Honolulu"},{"2":"Hilo"},{"3":"Lahaina"},{"4":"Kona"}][/return ] [/case] [default] [return][["No city"]][/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-jQuery/ ) 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 the following code to some nice Webdna... I have started with something looking like the following, but I'm not sure I'm going the right direction. [search db=../admin/clubs.db&neLIGUEdata=FINDALL®IONsumm=t] [arrayset name=region&dim=2,[numfound]] [founditems]([SKU])=[region] [/founditems][/arrayset] [/search] Thanks in advance Lawrence 'Montana'); $array[] = array('2' => 'New York'); $array[] = array('3' => 'Texas'); } else { $array[] = array('0' => 'No state'); } } elseif ($_GET['_name'] == 'state') { if ( $_GET['_value'] == 2 )//New York { $array[] = array('1' => 'New York'); $array[] = array('2' => 'Another city'); } else { $array[] = array('0' => 'No city'); } } else { $array[] = array('1' => 'Data 1'); $array[] = array('2' => 'Data 2'); $array[] = array('3' => 'Data 3'); } echo json_encode( $array ); ?> ------=_NextPart_000_0258_01CA9E5D.89509FF0 Content-Type: text/html; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable

This is actually very simple to do. Just change two = lines in 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 your server. Here is a template for you to use below. Just use a new case = statement for each new country/list of cities and follow the pattern. Don’t = forget you 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":"New York"},{"2":"Montana"},{"3":"Texa= s"},{"4":"Hawaii"}][/return]

[/case]

[default]

[return][["No state"]][/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]<= /span>

[/case]

[default]

[return][["No city"]][/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 the following code to some nice Webdna...
I have started with something looking like the following, but I'm not = sure I'm going the right direction.

    [search db=3D../admin/clubs.db&neLIGUEdata=3DFINDALL&REGIONsumm=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[] =3D array('1' =3D> 'Data 1');
            = $array[] =3D array('2' =3D> 'Data 2');     
            = $array[] =3D array('3' =3D> 'Data 3');     
    }
    echo json_encode( $array );
    ?>

------=_NextPart_000_0258_01CA9E5D.89509FF0-- Associated Messages, from the most recent to the oldest:

    
  1. RE: [WebDNA] PHP Array translated to Webdna ("Olin Lagon" 2010)
  2. Re: [WebDNA] PHP Array translated to Webdna (Toby Cox 2010)
This is a multi-part message in MIME format. ------=_NextPart_000_0258_01CA9E5D.89509FF0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit This is actually very simple to do. Just change two lines in 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 your server. Here is a template for you to use below. Just use a new case statement for each new country/list of cities and follow the pattern. Don't forget you 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=run] -- code for country [showif [_id]=country] [switch value=[_value]] [case value=3] [return][{"1":"New York"},{"2":"Montana"},{"3":"Texas"},{"4":"Hawaii"}][/return] [/case] [default] [return][["No state"]][/case] [/default] [/switch] [/showif] -- code for state [showif [_id]=state] [switch value=[_value]] [case value=4] [return][{"1":"Honolulu"},{"2":"Hilo"},{"3":"Lahaina"},{"4":"Kona"}][/return ] [/case] [default] [return][["No city"]][/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-jQuery/ ) 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 the following code to some nice Webdna... I have started with something looking like the following, but I'm not sure I'm going the right direction. [search db=../admin/clubs.db&neLIGUEdata=FINDALL®IONsumm=t] [arrayset name=region&dim=2,[numfound]] [founditems]([SKU])=[region] [/founditems][/arrayset] [/search] Thanks in advance Lawrence 'Montana'); $array[] = array('2' => 'New York'); $array[] = array('3' => 'Texas'); } else { $array[] = array('0' => 'No state'); } } elseif ($_GET['_name'] == 'state') { if ( $_GET['_value'] == 2 )//New York { $array[] = array('1' => 'New York'); $array[] = array('2' => 'Another city'); } else { $array[] = array('0' => 'No city'); } } else { $array[] = array('1' => 'Data 1'); $array[] = array('2' => 'Data 2'); $array[] = array('3' => 'Data 3'); } echo json_encode( $array ); ?> ------=_NextPart_000_0258_01CA9E5D.89509FF0 Content-Type: text/html; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable

This is actually very simple to do. Just change two = lines in 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 your server. Here is a template for you to use below. Just use a new case = statement for each new country/list of cities and follow the pattern. Don’t = forget you 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":"New York"},{"2":"Montana"},{"3":"Texa= s"},{"4":"Hawaii"}][/return]

[/case]

[default]

[return][["No state"]][/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]<= /span>

[/case]

[default]

[return][["No city"]][/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 the following code to some nice Webdna...
I have started with something looking like the following, but I'm not = sure I'm going the right direction.

    [search db=3D../admin/clubs.db&neLIGUEdata=3DFINDALL&REGIONsumm=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[] =3D array('1' =3D> 'Data 1');
            = $array[] =3D array('2' =3D> 'Data 2');     
            = $array[] =3D array('3' =3D> 'Data 3');     
    }
    echo json_encode( $array );
    ?>

------=_NextPart_000_0258_01CA9E5D.89509FF0-- "Olin Lagon"

DOWNLOAD WEBDNA NOW!

Top Articles:

Talk List

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...

Related Readings:

$Append for Users outside the ADMIN group (1997) Before I Can Begin . . . (1998) URGENT: WebDNA Server Not Running (2003) possible, WebCat2.0 and checkboxes-restated (1997) Opinion: [input] should be called [output] ... (1997) [OT] SMTP Server for W2000 (2002) Search returns all, not 20 (1997) [TaxableTotal] - not working with AOL and IE (1997) syntax question, not in online refernce (1997) Req: Array Tags Explained, simple and clear (2004) Another issue with [Date format] (1998) Read and Write (2001) Using Plug-In while running 1.6.1 (1997) multiple record replace (2001) MySQL and Decimals (2004) Pgp&emailer (1997) WebCat2 - Getting to the browser's username/password data (1997) RequiredFields notes ... (1997) Possible Bug in 2.0b15.acgi (1997) [url] link (1998)