which technologies to use for forms created dynami

2019-09-14 18:14发布

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!

标签: forms dynamic
1条回答
女痞
2楼-- · 2019-09-14 19:02

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);

?>
查看更多
登录 后发表回答