Languages :: DHTML, JScript :: how to make a non-submittable FORM ? no action ? |
|||
| By: PHP newbee |
Date: 28/04/2006 09:24:50 |
Points: 20 | Status: Answered Quality : Excellent |
|
Hello, I try to set up a FORM like this : <form name="addprivcat" id="addprivcat" action="" method="POST"> <!--unused in fact--> <input type="hidden" name="editval" id="editval" value="0"> <input type="hidden" name="previd" id="previd" value="0"> <input type="hidden" name="cat" id="cat" value="$thecat"> <input type="hidden" name="id_user" id="id_user" value="{$_SESSION['sess_id']}"> <table width="100%"><tbody><tr><td align="right" width="*"><center><b>Add Category</b></center></td><td align="right" width="15"> <a href="javascript:hide_addprivcat_popup();"><img src="$courant/images/cross_icon.jpg" width="9" height="9" border="0" alt="X"></a></td></tr> <tr><td align="right">Enter Title: <input name="formtitre" id="formtitre" type="text" size="40" maxlength="80" value=""></td><td> </td></tr> <tr><td colspan="2" align="right"><a href="javascript:appliquer4(false);"><img src="$courant/images/icon_ok.png" border="0" alt="V"></a></td></tr> </tbody></table> </form> As you can see, there is only a TEXT input field. This FORM is contained on a layer, as demonstrated by the closing link hide_addprivcat_popup(). The actual method of sending the data is via appliquer4(); which validates the form data and then sends a GET request before hiding the layer. There is no submit() so in fact, as I wrote in a comment, the FORM settings are unused. Now my problem is that this worked very well ***until I set up an automatic validation*** via the RETURN/ENTER key with code like this : <div id="addprivcat_popup" class="opaque popup" OnKeyDown="defaultvalid(event);"> <script language="JavaScript" type="text/javascript"> function defaultvalid(event) { if ((event.which && event.which == 13) || (event.keyCode && event.keyCode == 13)) { appliquer4(false); return false; } else return false; } The DIV is the layer. This works somewhat, ***but*** the FORM gets submitted ! As the action="" it gets submitted to $PHP_SELF in fact ! (same page) This is a major problem for me. I don't want the FORM to be submitted (the field formtitre isn't expected in $_POST[], and in fact no submit-handling function does exist. As far as I could debug, it seems to me that the FORM is submitted when I press ENTER (although I wonder why, there is no type="submit" field and I don't do a form.submit() ), and then my code processing takes place and sends correctly the data via GET in the appliquer4() function call. WHY ? And HOW TO MAKE a non-submittable FORM ? Thanks ! |
|||
| By: VGR | Date: 28/04/2006 09:29:56 | Type : Answer |
|
| Hello, I think this simple solution should be the best for you : <form name="addprivcat" id="addprivcat" action="#" OnSubmit="return false;" Best regards |
|||
|
Do register to be able to answer |
|||
©2010 These pages are served without commercial sponsorship. (No popup ads, etc...). Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE.
Please DO link to this page!








