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
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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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