Schlo_50 Posted December 7, 2007 Share Posted December 7, 2007 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 Quote Link to comment Share on other sites More sharing options...
PHP_PhREEEk Posted December 7, 2007 Share Posted December 7, 2007 The second parameter to count() cannot be a string. Did you check php.net? What are you expecting the second parameter to do for you? The answer to your original question is, no, PHP cannot do that. Javascript does that... PhREEEk Quote Link to comment Share on other sites More sharing options...
Schlo_50 Posted December 7, 2007 Author Share Posted December 7, 2007 Ouch, I really need to know how to do this and i have no knowledge of javascript whatsoever. lol I guess it's back to Google for a tutorial.. Thanks Freak Quote Link to comment Share on other sites More sharing options...
PHP_PhREEEk Posted December 7, 2007 Share Posted December 7, 2007 You might be interested in Expand/Collapse http://www.blakems.com/archives/000087.html PhREEEk Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.