我需要一些帮助来修改 网络表单模块 这样它就可以为我的项目工作。我现在使用 Webform 来处理单页、基本表单,效果非常好。我需要能够获取多个网络表单并根据用户所做的一些初始选择将它们串在一起。让我举个例子。

用户被发送到“一般信息”网络表单,在其中输入姓名和生日等信息。还有 3 个带有复选框的问题,分别是:

“你有房子吗”

“你有车吗”

“你有小孩吗”

用户可以选择全部、部分或不选择任何选项。根据用户的选择,一旦他们按下提交按钮,他们将被发送到“房屋表单”、“汽车表单”和/或“儿童表单”。

当他们填写完所有表格后,系统会向管理员发送一封电子邮件,就像现在的网络表单一样。该信息不需要存储在网站的数据库中,电子邮件就足够了。

那么,关于如何做到这一点有什么建议吗?除了 Webform 之外还有其他更合适的吗?或者(如果我超级幸运)是否已经存在一个可以满足我需要的模块?

有帮助吗?

解决方案

条件字段是即将推出的 Webform 版本 3 的一项功能。参见相关内容 问题测试版 这是两周前发布的。

其他提示

为什么不能简单地显示或隐藏,表单元素作为必需的,而不是重定向其他潜在-多个后续,形式?

使用以下(X)HTML:

<form enctype="form/multipart" method="post" action="">

    <fieldset>

        <legend>Cars:</legend>

        <label for="cars">Do you have one, or more, cars?</label><input name="cars" id="cars" class="test" type="checkbox" />
        <fieldset class="subSection" id="cars">
            <input type="radio" name="numCars" value="1" />One
            <input type="radio" name="numCars" value="2" />Two
            <input type="radio" name="numCars" value="3" />Three
        </fieldset>

    </fieldset>

    <fieldset>

        <legend>Children:</legend>

        <label for="kids">Do you have one, or more, children</label><input name="kids" id="kids" class="test" type="checkbox" />
        <fieldset class="subSection" id="kids">
            <input type="radio" name="numKids" value="1" />One
            <input type="radio" name="numKids" value="2" />Two
            <input type="radio" name="numKids" value="3" />Three
        </fieldset>

    </fieldset>

    <fieldset>

        <legend>Houses:</legend>

        <label for="houses">Do you have one, or more, houses</label><input name="houses" id="houses" class="test" type="checkbox" />
        <fieldset class="subSection" id="houses">
            <input type="radio" name="numHouses" value="1" />One
            <input type="radio" name="numHouses" value="2" />Two
            <input type="radio" name="numHouses" value="3" />Three
        </fieldset>

    </fieldset>

</form>

和jQuery的(可以整理,但我仍然在它新的自己......这样而已,我怕“概念验证”):

$(document).ready(
    function() {
        // hide the sub-sections
        $('fieldset.subSection').hide();

        // show subsections onClick of the .test checkboxes
        $('input.test').click(
            function() {
                $(this).next('fieldset.subSection').slideToggle('slow');
            }
        )
    }
);

现场演示当前位于: http://davidrhysthomas.co.uk/so/subForms.html

创建自定义模块,将捕获通过hook_nodeapi并重定向到适当的形式或页面...

提交
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top