0

i want to add (+)to add more than textfield for phone

<form method="post" action="" enctype="multipart/form-data">
  <table width="800" border="0" dir="rtl" style="direction:ltr;">
   <tr>
      <td scope="col" style="direction:rtl;"><label for="textfield">name</label>
        
        <div align="right">
          <input type="text" name="person_name" id="person_name"/>
          </div></td>
     
    </tr>
    <tr>
      <td style="direction:rtl;"><label for="textfield">job</label>
        
        <div align="right">
          <input type="text" name="person_job" id="person_job" />
          </div></td>
     
    </tr>
    <tr>
      <td style="direction:rtl;"><label for="label">mobile</label>
        
        <div align="right">
          <input type="text" name="person_mobile" id="person_mobile" />
          </div></td>
    
    </tr>
    <tr>
      <td style="direction:rtl;"><label for="label2" >phone</label>
        
        <div align="right">
          <input type="text" name="person_phone" id="person_phone" />
          </div></td>
    
    </tr>
    <tr>
      <td style="direction:rtl;"><label for="label3">email</label>
        
        <div align="right">
          <input name="person_email" type="text" id="person_email"   />
          </div></td>
      
    </tr>
    <tr>
      <td><label for="label4"></label>
        
        <div align="right"></div></td>
   
    </tr>
	 <tr>
          <td colspan="2"><p align="right">
              <input name="add" type="submit" id="add" value="add" />
          </p></td>
        </tr>
  </table>
</form>

and how to insert to mysql db?
any help?

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by diafol
0

Just quickly - do you really want to use direction:rtl? Would text-align:right be more appropriate? AFAIK, rtl is used for right-to-left languages, not for simple alignment.

This is your barebones phone field:

<td>
 <label for="person_phone" >phone</label>
 <input type="text" name="person_phone[]" id="person_phone" />
</td>

I assume you mean add more <input> fields? You can add as many as you like, using the same: name="person_phone[]". This means the $_POST variable will be an array. Easy. However, DO NOT use identical ids - they must be unique. You can create dynamic inputs based on the number you want:

<?php
$num = 0;
while($num < 5){ //add 5 inputs
 echo "\n\t<input type=\"text\" name=\"person_phone[]\" id=\"person_phone_{$num}\" />";
 $num++;
}
?>

If you want javascript to generate these one at a time (with a [+] button), see jQuery for examples.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.