“如何读取刚填入一表单(如select)中的数据类容”,以实现要根据此类容再查询数据库,再把查询结果显示在另一表单(如input)中,最后提交整个表单写数据库?

解决方案 »

  1.   

    提交表单 get或者post方式 后台$_GET或者$_POST接受值
    test.php
    <form method="post" action="test.php">
    <select name="you">
    <option value="f">man1</option>
    <option value="u">man2</option>
    <option value="c">man3</option>
    <option value="k">man4</option>
    </select>
    <input type="submit" value="提交">
    </form>
    </body>
    <?php
    $man = $_POST['you'];
    echo $man;
    ?>
      

  2.   

    用javascript获取选取的下拉列表值,然后通过url传参给php处理,把返回的结果写入input,最后submit这个表单
      

  3.   

    如果页面不刷新话,
    用ajax来实现吧.获取表单内容,提交到后台处理查询,接收返回的结果,显示在表单里.
      

  4.   

    jquery 里面有一个有一个fieldSerialize 将表单的提取。比较好用。
    /**
     * Serializes form data into a 'submittable' string. This method will return a string
     * in the format: name1=value1&amp;name2=value2
     */
    $.fn.formSerialize = function(semantic) {
        //hand off to jQuery.param for proper encoding
        return $.param(this.formToArray(semantic));
    };/**
     * Serializes all field elements in the jQuery object into a query string.
     * This method will return a string in the format: name1=value1&amp;name2=value2
     */
    $.fn.fieldSerialize = function(successful) {
        var a = [];
        this.each(function() {
            var n = this.name;
            if (!n) return;
            var v = $.fieldValue(this, successful);
            if (v && v.constructor == Array) {
                for (var i=0,max=v.length; i < max; i++)
                    a.push({name: n, value: v[i]});
            }
            else if (v !== null && typeof v != 'undefined')
                a.push({name: this.name, value: v});
        });
        //hand off to jQuery.param for proper encoding
        return $.param(a);
    };
    js 的名称为 jquery.form.js 自己上google 搜一下。
      

  5.   

    这个问题其实很简单,至少有两种方式可以做:
    1.用AJAX实现,如果东西比较简单,用自己写Ajax代码,直接用xmlhttprequest对象实现,如果是大应用的话,可以使用JQuery及其组件实现,刚上面也有兄台提供了滴。
    2.如果你的服务器好的话,也可以考虑用同步实现,就用PHP来完成这些工作。第一步是显示所有的空白表单让用户输入,完成表单一的输入后提交表单到php,php读取表单一的数据后查询数据库,然后将表单一提交的数据写到表单一的控件里,将查询的结果写到表单的控件里,等用户确认后再次提交到php,让php获取两张表单的数据后存入数据库。其间的的一些操作完全可以根据个人喜好和性能最后化为前提来做优化处理,这个你可以自己把握