使用链接将数据发送到表单

时间:2012-07-27 01:06:21

标签: php jquery mysql json jquery-easyui

我不知道要编写脚本,点击链接时,它会将数据发送到表单。我想做的是。当用户点击链接数据将出现在表单中。下面是我的链接。从数据库生成。

<div id="menu_bar"  region="west" split="true" title="Pages listing" style="width:200px;padding:10px;">
<?php 
$parent = mysql_query("select * from pages where parent = 0");
            echo "<ul id='sitemap'>";

        while($row = mysql_fetch_array($parent)){
            $parent_id = $row['id'];
            $parent_name = $row['name'];
        echo "<li><a href='#' onclick='editPage()'>$parent_name ($parent_id)</a>";
        echo "<ul>";
                $child = mysql_query("select * from pages where parent = '$parent_id'");
                while($row = mysql_fetch_array($child)){
                $child_id = $row['id'];
                $child_name = $row['name'];
                    echo "<li><a href='list2.php?id=$child_id' onclick='editPage()'>$child_name ($child_id)</a></li>";
                }
        echo "</ul>";
        }

        echo "</li>";
        echo "</ul>";
?>
</div>

表格。          
         
    基本信息         
            名称:
            
        
        
            家长:
            
        
         
            订购:
            
                   
            正文:
             
                  
            特别声明:
            
                   

请帮助我,我还在编程领域。即时通讯使用PHP,JSON,JQUERY,EASY-UI。

由于

1 个答案:

答案 0 :(得分:0)

如果您想在新页面中修改页面详细信息,则无需调用onclick='editPage()'而不是通过href传递页面网址。

<?php 
    $parent = mysql_query("select * from pages where parent = 0");
                echo "<ul id='sitemap'>";

            while($row = mysql_fetch_array($parent)){
                $parent_id = $row['id'];
                $parent_name = $row['name'];
            echo "<li><a href='edit_page.php?id=".$row['id']."' >$parent_name ($parent_id)</a>";
            echo "<ul>";
                    $child = mysql_query("select * from pages where parent = '$parent_id'");
                    while($row = mysql_fetch_array($child)){
                    $child_id = $row['id'];
                    $child_name = $row['name'];
                        echo "<li><a href='edit_page.php?id=".$row['id']."' >$child_name ($child_id)</a></li>";
                    }
            echo "</ul>";
            }

            echo "</li>";
            echo "</ul>";
    ?>

编辑页面代码应该是这样的

<?php 
    $id = $_REQUEST['id'];
    //use ur table name here
    //I am considering that ur table contain all the required information
    $result = mysql_query("select * from table where id='".$id."'");
    $row = mysql_fetch_assoc($result);
    ?>
    <form>
    Name <input type="text" name="name" id="name" value="<?php echo $row['name']; ?>" />
    Parent <input type="text" name="name" id="name" value="<?php echo $row['parent']; ?>" />
    Order <input type="text" name="name" id="name" value="<?php echo $row['order']; ?>" />
    Body <input type="text" name="name" id="name" value="<?php echo $row['body_text']; ?>" />
    Special <input type="text" name="name" id="name" value="<?php echo $row['special']; ?>" />
    </form>

希望这会对你有所帮助。