0

My users can enter more than one address but I want an actual button that generates the extra fields as only one address is compulsory and empty fields will look ugly! I also need the extra addresses to go into mysql database. How would I do with Javascript if PHP is not possible Some code that may help:

<td width="732" valign="top"><p>
<h3 class="main">Address Details</h3>
<p class="normal"> You are able to add up to 3 addresses but only 1 is compulsory. 
However it would be helpful if you could insert 3 addresses:
<ul>
 <li>Permanent home address</li>
 <li>Postal address (where you will be from June to September)</li>
 <li>Local address (where you currently live)</li>
</ul>    
<?php   
 if(!empty($err))  {
   echo "<div class=\"msg\">";
  foreach ($err as $e) {
    echo "* $e <br>";
    }
  echo "</div>";    
   }
 ?>
 <br>
<form action="address.php" method="post" name="regForm" id="regForm" >
<table width="95%" border="0" cellpadding="3" cellspacing="3" class="forms">
<tr> 
<td>Street<span class="required"><font color="#CC0000">*</font></span> 
</td>
<td><input name="Street"  type="text" id="Street" class="required" size="50"> 
</tr>
<tr> 
<td>Line 2
</td>
<td><input name="Line2"  type="text" id="Line2" class="required" size="50"> 
</tr>
<tr> 
<td>Line 3
</td>
<td><input name="Line3"  type="text" id="Line3" class="required" size="50"> 
</tr>
<tr> 
<td>Town<span class="required"><font color="#CC0000">*</font></span> 
</td>
<td><input name="Town"  type="text" id="Town" class="required" size="30"> 
</tr>
<tr> 
<td>Postcode<span class="required"><font color="#CC0000">*</font></span> 
</td>
<td><input name="Postcode"  type="text" id="Postcode" class="required" size="10"> 
</tr>
<tr> 
<td>Country <font color="#CC0000">*</font></span></td>
<td><select name="Country" class="required" id="select8">
            <option value="" selected></option>
            <option value="Afghanistan">Afghanistan</option>
            <option value="Albania">Albania</option>
           (etc)
          </select></td>
</tr>
<tr> 
<td>Telephone Number<span class="required"><font color="#CC0000">*</font></span> 
</td>
<td><input name="Tele"  type="text" id="Tele" class="required" > 
</tr>
<tr> 
<td>Fax<span class="required"><font color="#CC0000">*</font></span> 
</td>
<td><input name="Fax"  type="text" id="Fax" class="required" > 
</tr>
<tr> 
<td>Mobile<span class="required"><font color="#CC0000">*</font></span> 
</td>
<td><input name="Mobile"  type="text" id="Mobile" class="required" > 
</tr>
<tr> 
<td>Type <font color="#CC0000">*</font></span></td>
<td><select name="Type" class="required" id="select8">
            <option value="" selected></option>
            <option value="H">Home</option>
            <option value="P">Postal</option>
            <option value="L">Local</option>


</table>
<p align="center">
<input name="doAddress" type="submit" id="doAddress" value="Submit">

1 Answer 1

2

to fix your parse error - put ; at the end of line $numrows = 0 + $_GET['numrows']

to generate more fields dynamically - use javascript, really, it's way better for this task than php

Sign up to request clarification or add additional context in comments.

2 Comments

Can you help me with the javascript please
check stackoverflow.com/questions/2145012/… and stackoverflow.com/questions/171027/add-table-row-in-jquery. these examples use jQuery - it is pretty easy to learn, you shouldn't have any problems in achieving your task

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.