JavaScript
--
Questions
--
Followers
Top Experts
can you also show me how to store the values in mysql database?
Zero AI Policy
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
https://iconoun.com/demo/temp_moses.php
Original form

Form filled in

Result of running the script

<?php // demo/temp_moses.php
/**
* https://www.experts-exchange.com/questions/29026356/HOW-TO-GROUP-RADIO-BUTTONS-THAT-ARE-DYNAMICALLY-GENERATED-BY-CLICKING-A-BUTTON.html
*/
error_reporting(E_ALL);
// SHOW THE REQUEST VARIABLES
if (!empty($_POST))
{
foreach ($_POST['person'] as $key => $val)
{
echo PHP_EOL . "<br>Person #$key is $val, with gender:" . $_POST['gender'][$key];
}
}
// CREATE OUR WEB PAGE IN HTML5 FORMAT, USING HEREDOC SYNTAX
$htm = <<<HTML5
<!DOCTYPE html>
<html dir="ltr" lang="en-US">
<head>
<meta charset="utf-8" />
<meta name="robots" content="noindex, nofollow" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>HTML5 Page With Radio Buttons</title>
</head>
<body>
<form method="post">
<input name="person[1]" placeholder="Person #1" />
<input type="radio" name="gender[1]" value="m" />M
<input type="radio" name="gender[1]" value="f" />F
<br>
<input name="person[2]" placeholder="Person #2" />
<input type="radio" name="gender[2]" value="m" />M
<input type="radio" name="gender[2]" value="f" />F
<br>
<input name="person[3]" placeholder="Person #3" />
<input type="radio" name="gender[3]" value="m" />M
<input type="radio" name="gender[3]" value="f" />F
<br>
<input type="submit" />
</form>
</body>
</html>
HTML5;
// RENDER THE WEB PAGE
echo $htm;
https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html
There are millions of MySQL examples online. A few of the important ones are available here:
https://www.experts-exchange.com/articles/11177/PHP-MySQL-Deprecated-as-of-PHP-5-5-0.html






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
thanks for your effort!!!
<script>
$(document).ready(function() {
function addMore() {
var count = $('DIV.product-item').length
if (count >= 2) {
alert("only three staff allow");
count++;
return false;
}
$("<DIV>").load("input.php", function() {
$("#product").append($(this).html());
});
}
function deleteRow() {
$('DIV.product-item').each(function(index, item){
jQuery(':checkbox', this).each(function () {
if ($(this).is(':checked')) {
$(item).remove();
}
});
});
}
//////////////////////////
})
</script>
this is the php file that is being call by the above script when the add more staff button is click
<?php
echo '
<DIV class="product-item1 float-clear" style="clear:both;" >
<input type="checkbox" name="item_index[]" />
<div class="form-group">
<DIV class="col-sm-4"><input type="text" class="form-control" name="stfname[]" placeholder ="First Name"/><br></DIV>
<DIV class="col-sm-4"><input type="text" class="form-control" name="stlname[]" placeholder ="Last Name"/><br></DIV>
<DIV class="col-sm-4"><input type="text" class="form-control" name="stcommunity[]"placeholder ="Street/Community"/><br></DIV>
<DIV class="col-sm-4"><input type="text" class="form-control" name="stphone[]"placeholder ="Phone Number"/><br></DIV>
<DIV class="col-sm-4"><input type="text" class="form-control" name="stemail[]"placeholder ="Email Address"/><br></DIV>
<DIV class="col-sm-1"><input type="radio" name="sex" class="radio-inline" value="Male">Male<br><br></div
<DIV class="col-sm-1"><input type="radio" name="sex" class="radio-inline" value="Female">Female<br><br></div>
<DIV class="col-sm-4"><input type="text" class="form-control" name="stposition[]"placeholder ="Position"/><br></DIV>
<DIV class="col-sm-4"><input type="text" class="form-control" name="stqualification[]"placeholder ="Qualification"/></DIV>
<DIV class="col-sm-4"><input type="text" class="form-control" name="stexperience[]"placeholder ="Year of Experience"/><br></DIV>
</DIV></div>
';
?it's called "Input.php"
when the add more botten is click, the php file (input.php) is call on a main html page in a div with an id called "product"

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
JavaScript
--
Questions
--
Followers
Top Experts
JavaScript is a dynamic, object-based language commonly used for client-side scripting in web browsers. Recently, server side JavaScript frameworks have also emerged. JavaScript runs on nearly every operating system and in almost every mainstream web browser.
