View Full Version : Button write more than once?

01-20-2010, 03:46 PM
//if (isset($_POST[''])) {


<form name="tbCreate" method="post">
Table name:<br />
<input type="text" name="tableName"><br />
if (isset($_POST['addColumn'])) {
echo "Column Name: <input type=\"text\" name=\"columnName[]\"><br />";
<input type="submit" name="addColumn" value="Add Column">

Is there a way that the addColumn button can be clicked more than once, so that I can get more columnName fields?

01-20-2010, 04:07 PM
Rather than going to the server each time you would be better using javascript. Each time the btnAddParam button is clicked it will get the div with id additionalParams and add the new item to the content

<div id="additionalParams">
<input name="btnAddParam" type="button" alt="Add Param" value="Add Param" onclick="addParameter();"/>

<script language="JavaScript" type="text/javascript">
function addParameter() {
$('additionalParams').update($('additionalParams').innerHTML + <input type="text" id="requestParamName" name="requestParamName[]"/>');

01-20-2010, 06:19 PM
Problem with JavaScript though is that some users may have it disabled.

01-21-2010, 10:00 AM
Sure its a possiblility. Problem with doing it via server calls however is that you will need to store all the currently entered user info in every field for displaying again on reload etc. I know I would be peeved if i had entered 30 column names etc then clicked add button and it reloaded with 31 columns all blank.

I would use Javascript as default, do a check to see if they have javascript and if not present them with a form saying how many columns do you need? Then post it to itself and use a php loop to create the correct number of columns.