|
|
|
|
|
|
| |
table.php
| <script language="javascript" type="text/javascript">
function add(count){
var temp="";
temp=temp+"<table width='740' align='center' border=0>"
temp=temp+"<tr><td></td><td style='border-style:none' align='left'>"
temp=temp+"<input type='text' name=row1"+count+" size='20' maxlength='100'>"//row2
temp=temp+"</td>"
temp=temp+"<td style=border-style:none align='right'>"
temp=temp+"<input type=text name=row2"+count+" size='10' maxlength='10'>"//row12
temp=temp+"</td>"
temp=temp+"<td style=border-style:none align='right'>"
temp=temp+"<input type=text name=row3"+count+" size='10' maxlength='10'>"//row22
temp=temp+"</td><td style=border-style:none align='left'><a href='javascript:add("+(++count)+")'>+</a></td></tr>"
temp=temp+"</table>"
//alert(document.getElementById("divisions"));
document.all("divisions").innerHTML=document.all("divisions").innerHTML+temp;
}
</script>
<?php
print"<html><body>"; ////creating html and body tags
print "<form name='frm1' action='count.php' method='post'>"; ///creating form for posting
$count=1; //a counter to increment the rows
print "<div id='divisions'>"; ///creating division where the rows will be inserted
print "<table border=0 border-style='ridge' width=750 align='center'>"; /// first table
print "<tr><td></td></tr>";
print "<tr><td></td><td style=border-style:none align='left'>";
print "<input type='text' name=row1".$count." size='20' maxlength='100'>";//row11 creating first row with the names as row
print "</td>";
print "<td style=border-style:none align='right'>";
print "<input type=text name=row2".$count." size='10' maxlength='10'>";//row21
print "</td>";
print "<td style=border-style:none align='right'>";
print "<input type=text name=row3".$count." size='10' maxlength='10'>";//row31
print "</td><td style=border-style:none align='left'><a href='javascript:add(".++$count.")'>+</a></td></tr>"; /// hyperlink and counter to add rows using javascript
print "</table>"; ///end of first table
print "</div>"; //// division gets over
print "<table border=0 width=740 align='center'><tr><td colspan=5 align='center'><input type='submit'></td></tr></table>"; // table & submit buttonthird table end
print "</form>"; //end of form
print"</body></html>"; //end of html and body
?> | |
count.php
| <?php
foreach ($_POST as $key=>$value) {
print "$key = $value<br>";
}
?> | | |
|
| Pull Down Surfing - Surf on Change Categories : Java Script, MySQL, HTML and PHP, PHP, Databases | | | Remote Scripting: send form POST data to a script and insert the results into a page without refreshing the page. Categories : PHP, AJAX, HTML and PHP, Java Script | | | Tree Menu Dynamic (+Static) with Loading in Progress.. Categories : PHP, Java Script, HTML and PHP | | | OverEasy - PHP generated JavaScript to do mouseovers on
your pages. Modify one file and one function does it all
for you! Categories : PHP, Java Script, HTML and PHP, MySQL | | | This PHP function creates dropdown select lists for time and date that you can change, outputs a 14 char MySQL timestamp in a text field Categories : PHP, MySQL, Java Script, HTML and PHP | | | Function that allows a Javascript cookie to be set after HTML has been outputted to the page.
Categories : PHP, Java Script, Cookies, HTML and PHP | | | Local-to-user date and time display regardless of time zone or where the website's server is located Categories : PHP, Date Time, HTML and PHP, Java Script | | | PHP3: Formmail. Just a cgi formmail, but than in PHP. It is easy to use! Categories : HTML and PHP, Email, PHP, Perl, HTML and PHP | | | Newbie Notes #9 - Hyperlinking a post Categories : PHP, Java Script, HTML and PHP, Beginner Guides | | | PHP4 session helper HTML file.
Categories : PHP, Java Script, HTML and PHP, Sessions | | | Dynamic Calender in PHP, Javascript and HTML. Categories : PHP, Java Script, HTML and PHP, Calendar | | | Validator 98 - a PHP-script to generate form-validation-code in JavaScript. Categories : Complete Programs, Java Script, PHP, HTML and PHP | | | a function that builds an HTML select list from any mysql table. Categories : PHP, MySQL, HTML and PHP | | | Message of the Day - Random Message (Needs MySQL!) Categories : Databases, HTML and PHP, PHP, MySQL | | | Alternating background color for HTML table rows Categories : PHP, Databases, MySQL, HTML and PHP | |
| | | | matthew waygood wrote :1340
Nice little bit of script, but thought it a bit stange you printed the first form when you have the javascript there to do it for you. Also no need for the PHP bit, as you can use javascript to hold the count.
Heres the re-write for you:-
<script language="javascript" type="text/javascript">
count=1;
function add(count){
var temp="";
temp=temp+"<table width=`740` align=`center` border=0>"
temp=temp+"<tr><td></td><td style=`border-style:none` align=`left`>"
temp=temp+"<input type=`text` name=row1"+count+" size=`20` maxlength=`100`>"//row2
temp=temp+"</td>"
temp=temp+"<td style=border-style:none align=`right`>"
temp=temp+"<input type=text name=row2"+count+" size=`10` maxlength=`10`>"//row12
temp=temp+"</td>"
temp=temp+"<td style=border-style:none align=`right`>"
temp=temp+"<input type=text name=row3"+count+" size=`10` maxlength=`10`>"//row22
temp=temp+"</td><td style=border-style:none align=`left`><a href=`javascript:add("+(++count)+")`>+</a></td></tr>"
temp=temp+"</table>"
//alert(document.getElementById("divisions"));
document.all("divisions").innerHTML=document.all("divisions").innerHTML+temp;
}
</script>
<html>
<body>
<form name=`frm1` action=`count.php` method=`post`>
<div id=`divisions`>
<script language="javascript" type="text/javascript">
add(count);
</script>
</div>
<input type="submit" value="submit"/>
</form>
</body>
</html>
| |
|
|
|