用于动态创建表单的哪些技术? [英] which technologies to use for forms created dynamically?

查看:121
本文介绍了用于动态创建表单的哪些技术?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

新秀请求(来自学生)关于哪些技术(语言,包,图书馆等)最适合用于解决给定问题的请求。我知道我必须花时间学习2-4技术来实现我所想到的解决方案,但我发布这个问题至少跳过技术研究部分。



我想创建一个将被发送给〜500个用户的Web表单。或者实际上〜500个版本/这个webforms的实例,因为每个用户每个需要略有不同。对于每个版本/实例,在服务器/ Google工作表中某处的Mongo DB / Excel / CSV文件中都有相应的行,其中包含大约10到30个字之间的列(description)。想法是,基于相应的DB行创建表单内容。对于每个表单版本/实例,表单将显示与电子表格中描述列字段中的单词一样多的按钮。表单的用户将能够点击这些按钮来突出显示它们,然后可以点击表单的所有版面/实例的提交按钮。输出(即表示用户点击的按钮的字符串,例如000100 001000)将被写入DB /电子表格中的单独列中的同一行。



我使用模拟添加图片。
那么再次,你将用哪些技术来构建这样的表单?谢谢你的建议!

解决方案

这是我们以前使用的旧网页表单的一部分。这是用于本地主机使用的xamp或灯。这只是一个未经测试的模板,因为整个文件很漂亮,但整个工作,所以通过一些实验这应该是很好的



index.php

 < div> 
< form action =checkbox-form.phpmethod =post>
< p>评论< / p> < / TD>
< input type =texfieldid =commentsname =comments> < /输入>
< input type =checkboxid =CJL_Freshmanname =formDoor []value =CJL_Freshman/>创建JobLink(CJL)帐户
< input type =textname =student/>输入UserName< / input>
< input type =submitname =formSubmitvalue =提交/> < /输入>
< / form>
< / div>

从索引中的数据库中获取值,然后使用该值显示所需的内容

  $ link = mysqli_connect(localhost,root,pass); 
mysqli_select_db($ link,student);
$ result = mysqli_query($ link,SELECT * FROM testTable);
$ row = mysqli_fetch_array($ result);

if($ row ['comments']){
$ myvar = $ row ['comments'];

echo'< script> document.getElementById(comments)。value ='。$ myvar。';< / script>';
}

checkbox-form.php

 <?php 
$ studentUser = $ _POST ['student'];
$ link = mysqli_connect(localhost,root,pass);

// $ sql =CREATE TABLE $ student;
mysqli_select_db($ link,student);



if($ result = $ link-> query(SHOW TABLES LIKE$ studentUser。')){
if $ result-> num_rows == 1){
echoTable exists;
}
// create table if notnt
else {
$ sql =CREATE TABLE $ studentUser(
id INT(6)UNSIGNED AUTO_INCREMENT PRIMARY KEY,
评论varchar(255),
CJL_Freshman TINYINT(1));


($ i = 0; $ i <$ N; $ i ++)
{
echo($ aDoor [$ i]。 ;
if($ aDoor [$ i])
mysqli_query($ link,UPDATE $ studentUser SET $ aDoor [$ i] ='1');
}

mysqli_query($ link,UPDATE $ studentUser SET comments =('$ _POST [comments]'));

mysqli_close($ link);

?>


a rookie request for advice (from a student) about which technologies (languages, packages, libraries etc.) to best use to solve a given problem. I know I will have to spend time to learn 2-4 technologies to implement the solution I have in mind, but I am posting this question to at least skip the technologies research part.

I would like to create a web form which will be sent to ~500 users. Or actually ~500 versions/instances of this webforms, because each needs to be different slightly for every user. For each versions/instance there is a corresponding line in the Mongo DB /Excel/CSV file somewhere on a server / Google sheet, with a column ("description") holding roughly between 10 to 30 words. The idea is that a form content is created based on a corresponding DB line. For each form version/instance, the form would display as many buttons as there is words in the "description" column field in the spreadsheet. The user of the form would be able to click on these buttons to highlight them, and then would be able to click on the "Submit" button common for all the verstions/instances of the form. The output (i.e. string representing which buttons were clicked-on by the user e.g. "000100 001000") would be written to the same line in the DB/Spreadsheet in a separate column.

I add a picture with a mock-up. So again, which technologies would you use to build such forms? Thank you in advance for your advice!

解决方案

Here is a partial part of an old web form we used to use. This is for local host use xamp or lamp. This is just an untested template since the whole files are pretty darn big but the whole works so with some experimenting this should be fine

index.php

<div>
<form action="checkbox-form.php" method="post">
<p> Comments </p> </td>
<input type="texfield" id = "comments" name="comments"> </input>
<input type="checkbox" id="CJL_Freshman" name="formDoor[]" value="CJL_Freshman" /> Create JobLink(CJL) account
<input type ="text" name ="student" /> Enter UserName </input>
<input type="submit" name="formSubmit" value="Submit" /> </input>
</form>
</div>

get a value from database put in a script someone in index then use that value to display what you need

$link = mysqli_connect("localhost", "root", "pass");
mysqli_select_db ($link , "student" );
$result = mysqli_query($link,"SELECT * FROM testTable ");
$row = mysqli_fetch_array($result);

if($row['comments']){
    $myvar = $row['comments'];

echo '<script> document.getElementById("comments").value ="' . $myvar . '";</script>';
}

checkbox-form.php

<?php
$studentUser = $_POST['student'];
$link = mysqli_connect("localhost", "root", "pass");

//$sql = "CREATE TABLE $student";
 mysqli_select_db ($link , "student" );



if ($result = $link->query("SHOW TABLES LIKE '".$studentUser."'")) {
    if($result->num_rows == 1) {
        echo "Table exists";
    }
//create table if doesnt exist
else {
    $sql = "CREATE TABLE $studentUser (
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
comments varchar(255),
CJL_Freshman TINYINT(1) ) ";


    for($i=0; $i < $N; $i++)
    {
    echo($aDoor[$i] . " ");
    if($aDoor[$i])
    mysqli_query($link, "UPDATE $studentUser SET $aDoor[$i] = '1' ");
    }

 mysqli_query($link, "UPDATE $studentUser SET comments = ('$_POST[comments]') ");

mysqli_close($link);

?>

这篇关于用于动态创建表单的哪些技术?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆