Jump to content

[SOLVED] Text fields


Schlo_50

Recommended Posts

I have seen some websites that have dynamic forms which do things like add extra text fields when you click + field much like what this website does: http://www.mredkj.com/tutorials/tableaddcolumn.html

 

I know that these websites use javascript but is this not at all possible in PHP?

I have had a go although it has not been that successfull, i'll post what i have just so that you can see it and maybe ammend it if this idea is possible.

 

<?php
print "<form action=\"$_SERVER[php_SELF]\" method=\"post\" name=\"addfields\">";
$newfield = print "<input type=\"text\" name=\"add_1\" id=\"add_$num\" />";
print "<br />";
print "<input class=\"text\" type=\"submit\" name=\"add\" value=\"Add Field\" />";

if (isset($_POST['add']))
{
$strtnum[1] = 1;
$newfield = "<input type=\"text\" name=\"add_1\" id=\"add_$num\" />";
$num = count($strtnum, $newfield);


print "<p>";
print "<label>";
print "<input type=\"text\" name=\"add_1\" id=\"add_$strtnum\" />";
print "<br />";
print "</label>";
print "</p>";
print "<p>";

print "</p>";
print "<p>";

print "</p>";
print "<p>";
print "</form>";
print "</p>";

}
?>

 

Error: Warning: count() expects parameter 2 to be long, string given in C:\apachefriends\xamp.. on line 19

 

Any help or suggestions guys? Thanks

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.