简体   繁体   中英

how can i do this indefinitely? - by that I DO NOT mean an infinite while loop

I have a question with regards to a project I am working on - I am currently setting up a job application form and I want people to provide info like previous education, past work experience, and references, - so i got a section for education - where the form asks the user for the type of institution he/she attended, followed by the address, and the years (from:/to:), and whether they had graduated from that institution of learning or not - after the info is filled up for a particular institution, there is a "+" button that allows the potential employee to add more institutions - I got a picture attached in the following link: http://i59.tinypic.com/2418phg.png[/IMG]

once I click the "+" button, I get another input form drop down - but the problem is that it is the ONLY one I can add - I can't add any more after that and I would like to have the ability to do this infinitely!

You can see what I mean in the second image that I'm posting below - http://i59.tinypic.com/vhqpv9.png

Here's the code for the "+" button that I want to press to infinitely add as many institutions as possible to the question on education -

<button type="submit" id="Add" name="Add"  value="Add"/>+</button>
<?php while((isset($_POST["Add"]) && $_POST["Add"] == "Add")){
echo "<br>";
include('education.php');
echo "Address: <input size='20' type='text' id='instaddress' name='instaddress' maxlength='20' size='20'> From:<input type='text' id='instaddress' name='instaddress' size='4' > To: <input type='text' id='instaddress' name='instaddress' size='4'>
Did You Graduate?:  <input type='radio' id='graduate' name='graduate' value='yes'> Yes
<input type='radio' id='graduate' name='graduate' value='no'> No<button type='submit' id='Add' name='Add' value='Add'/>+</button><button type='submit' id='Minus' name='Minus'  value='Minus'/>-</button><br>
";
break;
}

?>

I also included a file ("education.php") in the php code above and the code for that is displayed below:

    <select name="institution" id="institution" onchange="showUser(this.value)">
<option <?php if(isset($_POST['institution'])) { echo $_POST['institution']; } ?>>Select Institution</option>
<?php

$sql1a = "SELECT * FROM institution ORDER BY institution asc";
$smt1a = $dbs->prepare($sql1a);
$smt1a -> execute();
while($row1a=$smt1a->fetch(PDO::FETCH_ASSOC))
{
if($row1a['institution']==$_GET['id3'])
echo("<option selected value=$row1a[institution]>$row1a[institution]</option>");
else
echo("<option value=$row1a[institution]>$row1a[institution]</option>");
}

//break;

?>

</select>

After the first time I press "+", I am not able to get a third or fourth or greater number of input form for the previous institutions that the job applicant has attended...

how can this matter be resolved so that I can include as many institutions as possible everytime that I press the "+" button?

what code am I missing?

please lemme know!

thnx a million!

As the commenters already said: You should provide a js script that copies the entire row. When you work with name="value[]" syntax then these values will be merged together into an array automatically. This way you can handle lots of form data as an array inside your evaluating php script.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM