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("txtSu ccessP") ?>" /> -->
<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("txtTe stTime") ?>" /> -->
<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:150p x;color:re d" /> <input id="btnImp" type="button" onclick="ShowUsers('import ed')" value="Imported users" style="border:0;width:150p x" />
</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='inde x.php?modu le=assignm ents'" 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"].su bmit();
</script>' ;
?>
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("txtSu
<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("txtTe
<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'
</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
</tr>
</table>
</form>
// This is the javascript
<?php
echo '
<script type="text/javascript">
document.forms["form1"].su
</script>' ;
?>
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.