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:

AppleScript/.db (was:FTP to WebStar) (2001) [WebDNA] WebDNA 7 on 8GB RAM server (2013) [WebDNA] Hard-coded db write delay when running certain code? (2011) WebCatalog and WebMerchant reviewed by InfoWorld (1997) [WebDNA] Accepting Payments on Site (2013) Cart# (1997) using showpage and showcart commands (1996) format_to_days on NT (1997) two of the same named db's open at once (1998) Cookie problems using Mozilla and Camino browsers (2004) Timeout question .. (2003) Searching for the end (1998) webcatalog [date] bug...not (1999) What's New Date (2002) [OT] Form POSTing with LONG variable (2007) unsubscribe (2000) Show shoppingcart after remove last item (1997) WebCat2b15MacPlugin - [protect] (1997) [WebDNA] Foreign characters (2009) (2009) question: webdelivery folder and file (1997)