Jump to content

Don't understand why it won't work


shadowcaster

Recommended Posts

Hello guys. I have a simple form on a page and I want to copy some field's data from one set to another, from the address field (a1) to another address field (pa1). Here is the JavaScript I'm using:

<script language="JavaScript1.2" type="text/JavaScript">
  function copyOver(){
document.form.pa1.value = document.form.a1.value;
document.form.pa2.value = document.form.a2.value;
document.form.pa3.value = document.form.a3.value;
  }</script>

and the html:

      <form name="form" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">    
        <tr><td width="260" valign="top">Current Address <font color="#FF0000">*</font> </td>            
        <td width="340"><input type="text" name="a1" style="width: 200;" class="contact" maxlength="50"><br>
		<input type="text" name="a2" style="width: 200;" class="contact" maxlength="40"><br>
		<input type="text" name="a3" style="width: 200;" class="contact" maxlength="30"></td>
                        <td> </td></tr>
        <tr><td width="260" valign="top">Permanent Address <font color="#FF0000">*</font> </td>            
        <td width="340"><input type="text" name="pa1" style="width: 200;" class="contact" maxlength="50"><br>
		<input type="text" name="pa2" style="width: 200;" class="contact" maxlength="40"><br>
		<input type="text" name="pa3" style="width: 200;" class="contact" maxlength="30"></td>            
        <td width="100" valign="top"><input name="copyOver" type="button" onClick="copyOver();" value="Same As Current"></td></tr>

 

When I click the button it doesn't do anything

Link to comment
https://forums.phpfreaks.com/topic/59325-dont-understand-why-it-wont-work/
Share on other sites

using a form starting between  tr's is a bad practice and will give you a problem on some browsers(I had that problem with ff I believe) .  I don't believe that will validate either.  either put the form tag before the table tag and then put the /form tag after the /table tag, or nest the entire form within a td /td

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.