怎么样能够实现这样的效果?
|--------|
|--------|(input text) button怎样实现点击button,把text的数据提交给数据中,实现无刷新数据更新?

解决方案 »

  1.   

    这个只需一些JS、Ajax技术就可以执行,楼主给个表单这样好做些。
      

  2.   

    <form id="myform" name="myform" method="post">
    <?php 
      foreach($results as $rs){
      $id=$rs->id;
      $login=$rs->login;
      //get names by id
      $name=$tool->get_col_value("users","name","login='$login'");
      $surname=$tool->get_col_value("users","surname","login='$login'");
      $user_type=$tool->get_col_value("users","user_type","login='$login'");
      $email=$tool->get_col_value("users","email","login='$login'");
      $join_date=$rs->join_date;
       $line_id="line".$id;  }
    ?>
      
      <tr <?php echo "id='$line_id'"; ?>  >
        <td height="25" style="padding-left:5px;" ><div align="right"><b><?php echo $login; ?></b></a></div></td>
        <td height="25"  align="center" >   <?php echo $name; ?></td>
        <td   align="center"><?php echo $surname; ?></td>
        <td   align="center">&nbsp;<?php echo $id; ?></td>
        <td width="13%" height="25"  align="center" ><input height="20"  width="80" name="<?php echo "score".$i;?>" type="text" value="<?php echo $class_score; ?>" /></td>
        <td width="5%"  align="center" ><?php echo $active_score; ?></td>
        <td height="25" align="center" <?php echo $text_color_class; ?> ><?php echo $active_img; ?></td>
      </tr><?php $i++;} ?> 
    </form>
      

  3.   

    将表单数据直接使用xmlhttprequest发送给保存数据的php程序,保存即可,可以是异步可以是同步,都是在后台执行的
      

  4.   

    你的button????在哪里???没有见到???
      

  5.   

      <tr <?php echo "id='$line_id'"; ?>  > 
        <td height="25" style="padding-left:5px;" > <div align="right"> <b> <?php echo $login; ?> </b> </a> </div> </td> 
        <td height="25"  align="center" >  <?php echo $name; ?> </td> 
        <td  align="center"> <?php echo $surname; ?> </td> 
        <td  align="center">&nbsp; <?php echo $id; ?> </td> 
        <td width="13%" height="25"  align="center" > <input height="20"  width="80" name=" <?php echo "score".$i;?>" type="text" value=" <?php echo $class_score; ?>" /> </td> 
        <td width="5%"  align="center" > <?php echo $active_score; ?> </td> 
        <td height="25" align="center" <?php echo $text_color_class; ?> > <?php echo $active_img; ?> </td> 
      </tr> <?php $i++;} ?> 
    </form>
    button 在红色后面,每个text后都有。。
      

  6.   

    推荐使用jquery,比prototype方便多了,用法也简单
      

  7.   

    楼上大哥jquery 该怎么写,请给出代码
      

  8.   

    触发事件
    $.post('执行文件',{参数:值,参数:值},function (data){
    if(data){
    //想干什么就干什么
    }
    });data是ajax传递过去执行文件后出来的结果,你在注释处处理自己的东西就可以了
      

  9.   

    能不能给个例子详细写。我加分。。
    我只想把当前text的velues提交给后台存数据库。
      

  10.   

    jquery +1http://jquery.com/官网有大量例子,很方便
      

  11.   

    你首先要先了解jquery的写法
    去下载jquery包
    用script src=''调用把你想要保存的text都给个id用button触发form的post或者get事件$.post('执行文件',{参数:值,参数:值},function (data){
    if(data){
    //想干什么就干什么
    }
    });
    这里的post看你自己定义的,如果你的form是get的就改成getjquery获取text的值方法是
    $('#id').val();执行文件上插入数据库随便你自己返回什么都可以,会赋值给data的如:
    触发代码
    $.post('handle.php',{text:$('#text').val()},function (data){
    if(data=='succ'){
    alert('成功');
    }else {
    alert('失败');
    }
    });
    执行代码
    $sql='';
    if($result=mysql_query($sql)){
    echo 'succ';
    }else {
    echo 'error';
    }
      

  12.   

    我以前也遇到过这样的问题,我是想把按扭做一张图片的,可是图片的只能是button后来我设置了一个css,
    用css来控制submit按扭的样式(也可以是图片的呀)哈哈,不知道你是不是想要这样的!!
    html:<input type="submit" value="登录" name="submitland" class="input" />
    css:input{
    border-bottom-width:0px; border-left-width:0px; border-right-width:0px; border-top-width:0px; background: url(../images/submit.gif) no-repeat; width: 106px; height: 24px; }
      

  13.   

    还是没解决问题,再加分。或者用下面jquery来实现。我只有html代码谁帮忙把test2.php给补上。
    <link href="editinplace.css" rel="Stylesheet" type="text/css" />
    <script src="jquery-1.1.3.pack.js" type="text/javascript"></script>
    <script>
    $(document).ready(function(){
    setClickable();
    });function setClickable() {
    $('#editInPlace').click(function() {
    var textarea = '<div><textarea rows="1" cols="0">'+$(this).html()+'</textarea>';
    var button  = '<div><input type="button" value="SAVE" class="saveButton" /> OR <input type="button" value="CANCEL" class="cancelButton" /></div></div>';
    var revert = $(this).html();
    $(this).after(textarea+button).remove();
    $('.saveButton').click(function(){saveChanges(this, false);});
    $('.cancelButton').click(function(){saveChanges(this, revert);});
    })
    .mouseover(function() {
    $(this).addClass("editable");
    })
    .mouseout(function() {
    $(this).removeClass("editable");
    });
    };function saveChanges(obj, cancel) {
    if(!cancel) {
    var t = $(obj).parent().siblings(0).val();
    $.post("test2.php",{
      content: t
    },function(txt){
    alert( txt);
    });
    }
    else {
    var t = cancel;
    }
    if(t=='') t='(click to add text)';
    $(obj).parent().parent().after('<div id="editInPlace">'+t+'</div>').remove();
    setClickable();
    }
    </script>    
    </head> <body>

    <h1>Edit-in-Place with jQuery</h1>

    <div id="editInPlace">
    <p>根据 <strong>jquery</strong>写的一个小的例子。点击这里可以编辑</p>
    </div>