visitor (0 QPoints)
  • FR
  • EN
  • NL
  • DE
  • ES
316 experts, 1194 registered users, 1659 questions already answered
European Experts Exchange, the very best site for high-quality IT solutions

New Improved Search!

 


05/10/2011 1h30 : Steve Jobs is dead, the father of Apple ][ is gone, we are all orphaned.

Languages :: DHTML, JScript :: how to make a non-submittable FORM ? no action ?


By: PHP newbee U.S.A.  Date: 28/04/2006 09:24:50  English  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">&nbsp;&nbsp;<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:&nbsp;<input name="formtitre" id="formtitre" type="text" size="40" maxlength="80" value=""></td><td>&nbsp;</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 English  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

EContact
browser fav
page generated in 289.253950 milliseconds

Why Google AdSense ads ?

compteur
 Ranking-Hits PageRank for this page