Hi nutron
I just post part of my code. now I send you whole. Please tell me
how can I solve my problem. Thanks
window.onload = function() {
// --- ordinary MooTreeControl example:
tree = new MooTreeControl({
div: 'mytree',
mode: 'files',
grid: true
},{
text: 'Root Node',
open: true
});
tree.disable(); // this stops visual updates while we're
building the tree...
var c = new String;
c = 'hikisu';
var node1 = tree.insert({text:'Subnode 1', id:c,
onSelect: function(state) {
if(state){
var myjson = new Object();
var b = new String;
b = '';
for(i = 0; i< 5; i++){
if(i > 0){
b = b +"&"+"d"+i +"=" +i
}else{
b = "d0"+"="+i
}
}
var myajax = new Request.JSON
({url:"test.php",method:'post',onComp
lete:function(mystring){
alert(mystring.p0.name);
alert(mystring.p1.name);
alert(mystring.p2.name);
alert(mystring.p3.name);
alert(mystring.p4.name);
}});
myajax.send(b);
var test = node1.insert({text:'test', id:'1.2',
onSelect: function(state) {
if(state){
var b = new String;
b = node1.id;
window.location.replace("test1.php?hikisu="+b);
}
}
});
var node2 = tree.insert({text:'Subnode 2', id:'2',
icon:'sample_icons.gif#1', open
icon:'sample_icons.gif#2'});
var node3 = tree.insert({text:'Subnode 3', id:'3'});
var node2_1 = node2.insert({text:'Subnode 2.1', id:'2.1'});
var node2_2 = node2.insert({text:'Subnode 2.2', id:'2.2',
color:'#ff0000'});
var node2_3 = node2.insert({text:'Subnode 2.3', id:'2.3'});
var index2 = new String;
for(j = 1; j <= 10; j++){
index2 = "2.2."+j
var index1 = node2_2.insert({text:'Subnode 2.2.'+j,
id:index2, color:'#00a
000',
var f = new String;
f = "2.2."+j;
onSelect: function(state) {
if(state){
var b = new String;
b = '';
for(i = 0; i< 5; i++){
if(i >0){
b = b +"&"+"d"+i +"=" +i
}else{
b = "d0="+f
}
}
var myajax = new Request.JSON
({url:"test.php",method:'post',onComp
lete:function(mystring){
alert(mystring.p0.name);
alert(mystring.p1.name);
alert(mystring.p2.name);
alert(mystring.p3.name);
alert(mystring.p4.name);
}});
myajax.send(b);
}
}
});
var node2_2_1_1 = index1.insert({text:'Subnode
2.2.1.'+j, id:'2.2.1.'+j, c
olor:'#0000ff'});
}
//var node2_2_1_1 = node2_2_1.insert({text:'Subnode 2.2.1.1',
id:'2.2.1.1', color:
'#0000ff'});
var node4 = tree.insert({text:'Subnode 4', id:'4',
icon:'sample_icons.gif#3'});
//tree.expand();
tree.collapse();
tree.enable(); // this turns visual updates on again.
}
function find_node() {
var node = tree.get( $('nodeid_input').value );
window.alert( node ? 'found: ' + node.text : 'not found...' );
}
</script>
It is mootree's example_1.html originally, I just reparied it.
The test.php is
<?php
require_once('HTML/AJAX.php');
require_once('HTML/AJAX/JSON.php');
session_start();
for($i = 0; $i < 5; $i++){
$k = sprintf("d%d",$i);
$e = sprintf("p%d",$i);
if(isset($_POST[$k])) $a[$e]['name'] = $_POST[$k];
}
$json = new HTML_AJAX_JSON();
$js = $json->encode($a);
print"$js";
?>
On 12月5日, 午前9:32, nutron <[EMAIL PROTECTED]> wrote:
> Hi Wang,
>
> I can't speak for others here, but this code example is both insufficient
> enough to help you. Debugging this requires that you inspect
> the response from the server. Use firebug to inspect your request and its
> response and then log the result to the firebug console to see what is in
> it. This forum is good for getting input, but it's not here to debug your
> code for you.
>
> On Thu, Dec 4, 2008 at 3:59 PM, wangsuya (via Nabble) <
> [EMAIL PROTECTED]<[EMAIL PROTECTED]>
>
>
>
>
>
> > wrote:
>
> > sorry post it again, I think that my title is unappridacate, not let
> > people understand my meanint so that I change title post again.
>
> > I tryed to make tree by loop and when select each node show this node
> > 's id, for example select "Subnode2.2.1" show "2.2.1" but it did not
> > success alway show "2.2.10" . Who know how to realize what I want?
> > Tanks.
>
> > Wang Suya
>
> > var index2 = new String;
> > for(j = 1; j <= 10; j++){
> > index2 = "2.2."+j
> > var f = new String;
> > f = "2.2."+j;
> > var index1 = node2_2.insert({text:'Subnode 2.2.'+j,
> > id:index2, color:'#00a000',
> > onSelect: function(state) {
> > if(state){
> > var b = new String;
> > b = '';
> > for(i = 0; i< 5; i++){
> > if(i >0){
> > b = b +"&"+"d"+i +"=" +i
> > }else{
> > b = "d0="+f
> > }
> > }
> > var myajax = new Request.JSON
> > ({url:"test.php",method:'post',onComp
> > lete:function(mystring){
> > alert(mystring.p0.name);
> > alert(mystring.p1.name);
> > alert(mystring.p2.name);
> > alert(mystring.p3.name);
> > alert(mystring.p4.name);
> > }});
> > myajax.send(b);
> > }
> > }
>
> > });
> > var node2_2_1_1 = index1.insert({text:'Subnode
> > 2.2.1.'+j, id:'2.2.1.'+j, c
> > olor:'#0000ff'});
> > }
>
> > ------------------------------
> > View message @
> >http://n2.nabble.com/When-make-node-and-node%27id-by-loop-and-when-se...
> > To start a new topic under MooTools Users, email
> > [EMAIL PROTECTED]<[EMAIL PROTECTED]>
> > To unsubscribe from MooTools Users, click here< (link removed) >.
>
> -----
> The MooTools Tutorial: http://www.mootorial.comwww.mootorial.com
> CNET Clientside: http://clientside.cnet.comclientside.cnet.com
> --
> View this message in
> context:http://n2.nabble.com/When-make-node-and-node%27id-by-loop-and-when-se...
> Sent from the MooTools Users mailing list archive at Nabble.com.-
> 引用テキストを表示しない -
>
> - 引用テキストを表示 -