2014-03-19 10:20
浏览 55


I'm building form with dynamic textboxes, if you click at the button "add", it appears a new textbox, i'm using php and javascript.

But i just can add into my database the value from the first textbox.

How can i insert multiple values into my database?

      <script src=""></script>
      <script type="text/javascript"><!--

         var counter = 2;
         $("#add").click(function () {
             alert("Too many boxes");
             return false;
             $("#textBoxes").append("<div id='d"+counter+"' ><label for='t2'> Textbox "+counter+"</label><input     type='textbox' id='t"+counter+"' > </div>

         $("#remove").click(function () {
             alert("No boxes");
             return false;
         // --></script>

            <form method="POST">
        <div id='textBoxes'>
            <label for="t1"> Textbox 1</label>
            <input name="nome" type='textbox' id='t1' ></div>

         <input type='button' value='add' id='add'>
         <input type='button' value='remove' id='remove'>
         <input type='submit' name="adicionar" value='adicionar'>
            $dbHost = 'localhost';
                       $dbUsername = 'hr';
                       $dbPassword = '';
                       $dbDatabase = 'r_inserir';

                       $db = mysql_connect($dbHost, $dbUsername, $dbPassword) or die ("Unable to connect to Database Server.");
                       mysql_select_db ($dbDatabase, $db) or die ("Could not select database.");



            $sql=  mysql_query("INSERT INTO registos(nome) values ('".$nome."')");
  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

3条回答 默认 最新

相关推荐 更多相似问题