To summarize from a previous question, the user selected a starting date, an ending date, and a region. From these choices, an array of weeks and regions are created, and users enter values ("points") that correspond to a particular week and region. This is what it looks like right now (some parts are hard-coded for testing purposes): Show
And the next part:
So basically, in this example it outputs 12 times:
I
want to catch the Is this a good idea or am I missing something fundamentally simpler? How to use PHP & Multiple Input Text Field/Textbox This tutorial how to using PHP read a variable from multiple input textbox ShotDev Focus: Example 1 php_multiple_textbox1.php <html> <head> <title>ShotDev.Com Tutorial</title> </head> <body> <form action="php_multiple_textbox2.php" method="post" name="form1"> <input type="text" name="txtSiteName[]"><br> <input type="text" name="txtSiteName[]"><br> <input type="text" name="txtSiteName[]"><br> <input name="btnSubmit" type="submit" value="Submit"> </form> </body> </html> php_multiple_textbox2.php <html> <head> <title>ShotDev.Com Tutorial</title> </head> <body> <? for($i=0;$i<count($_POST["txtSiteName"]);$i++) { echo "txtSiteName $i = ".$_POST["txtSiteName"][$i]."<br>"; } ?> </body> </html> Create a php file and save to path root-path/myphp/ Run Screenshot . . Example 2 (Create Element) php_multiple_textbox3.php <html> <head> <title>ShotDev.Com Tutorial</title> <script language="javascript"> function fncCreateElement(){ var mySpan = document.getElementById('mySpan'); var myElement1 = document.createElement('input'); myElement1.setAttribute('type',"text"); myElement1.setAttribute('name',"txtSiteName[]"); mySpan.appendChild(myElement1); var myElement2 = document.createElement('<br>'); mySpan.appendChild(myElement2); } </script> </head> <body> <form action="php_multiple_textbox4.php" method="post" name="form1"> <input type="text" name="txtSiteName[]"> <input name="btnButton" type="button" value="+" onClick="JavaScript:fncCreateElement();"><br> <span id="mySpan"></span> <input name="btnSubmit" type="submit" value="Submit"> </form> </body> </html> php_multiple_textbox4.php <html> <head> <title>ShotDev.Com Tutorial</title> </head> <body> <? for($i=0;$i<count($_POST["txtSiteName"]);$i++) { echo "txtSiteName $i = ".$_POST["txtSiteName"][$i]."<br>"; } ?> </body> </html> Create a php file and save to path root-path/myphp/ Run Screenshot . Download this script. Category: PHP & HTML Form and Element by admin (No Ratings Yet)Loading ... One Response to “How to use PHP & Multiple Input Text Field/Textbox”Leave a ReplyYou must be logged in to post a comment. How do I prompt in PHP?PHP is a server side language, it can't do alert messages on the client side. But you can use javascript within the php to do the alert. <? php //prompt function function prompt($prompt_msg){ echo("<script type='text/javascript'> var answer = prompt('".
What is readline PHP?Method 1: Using readline() function is a built-in function in PHP. This function is used to read console input.
How do I scan a value in PHP?The sscanf() function parses input from a string according to a specified format. The sscanf() function parses a string into variables based on the format string. If only two parameters are passed to this function, the data will be returned as an array.
How can I get input field value in PHP without form?If you don't want to submit a form, the only two other ways of accomplishing this are to click a link with the data as query parameters in the url, or use AJAX to send the data to the server in the background.
|