Link to home
Start Free TrialLog in
Avatar of williery10
williery10

asked on

form submit with javascript

Hi there,
hopefully someone can point me in the right direction here. I have a webpage with a form. I need to submit the form automatically and I am using Javascript.

Now when I actually push the submit button, the form is posted to its destination and does what its supposed to. However when I use the Javascript call it, it just reloads the page with the form repeatly. It appears to be repeatidly submitting it and not processing the data in the form.

I have put some code below.

All suugestions welcome

Thanks

The form

<form id="form1" method="post">    
    <table width="400px">
             <tr id="drpTr2">
            <td class="text_desc">
                <label class="desc_text">Success point/percent :</label>
            </td>
            <td>
                 <!--<input style="width:50px" type="text" name="txtSuccessP" id="txtSuccessP" value="<?php // echo xyz96zyx::xyz100zyx("txtSuccessP") ?>"  /> -->
                 
                 <input style="width:50px" type="text" name="txtSuccessP" id="txtSuccessP" value="90"  />
            </td>
        </tr>
               <tr id="drpTr3">
            <td class="text_desc">
                <label class="desc_text">Test time (in minutes) :</label>
            </td>
            <td>
          <!--       <input style="width:50px"  type="text" name="txtTestTime" id="txtTestTime" value="<?php// echo xyz96zyx::xyz100zyx("txtTestTime") ?>"  /> -->
                 <input style="width:50px"  type="text" name="txtTestTime" id="txtTestTime" value="45"  />
         
            </td>
        </tr>
    </table>

    <br>
    <hr />
    <table width="500">
        <tr>
            <td colspan="2">
                <input id="btnLcl" type="button" onclick="ShowUsers('local')" value="Local users" style="border:0;width:150px;color:red" />&nbsp;<input id="btnImp" type="button" onclick="ShowUsers('imported')" value="Imported users" style="border:0;width:150px" />
            </td>            
        </tr>
        <tr>
            <td valign="top" id="tdLocalUsers">
                 <!--<div id="div_grid"><?php //echo $grid_html ?></div> -->
                 <input  type=checkbox name=chkgrd[] value= <?php echo $_SESSION['user_id'] ?> checked />
            </td>
           
            <td valign="top" id="tdImportedUsers" style="display:none">
                    <!--<div id="div_grid"><?php // echo $imported_grid_html ?></div>-->
            </td>
           
        </tr>
    </table>
   
    <table>
        <tr>
            <td><input onclick="return CheckForm()" style="width:100px" type="submit" id="btnSave" name="btnSave" value="Save" /></td>
            <td><input onclick="javascript:window.location.href='index.php?module=assignments'" style="width:100px" type="button" id="btnCancel" name="btnCancel" value="Cancel" /></td>
        </tr>
    </table>

</form>

// This is the javascript

<?php

      echo   '
           <script type="text/javascript">
                  
                  document.forms["form1"].submit();
      </script>' ;
?>
SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Rainer Jeschor
Rainer Jeschor
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial