Join our DNN Community    (Newsletter, Tips, Tricks and Forums for DNN Skins & Modules)

 


 
Microsoft Gold Certified Partner - DNN Benefactor

DotNetNuke Powered! 


Thursday, November 20, 2008 Register · Login · Contact · Search:  
Company Solutions Portfolio Contact
Forums
General
The ever-powerful ListX module forum. Post your questions, new configuration ideas and reviews.
Subject: Submit form with enter key

You are not authorized to post a reply.   
Author Messages
radcoder1
Lightweight
Posts:22

08/25/2008 1:47 PM Alert 
Does anyone know how to submit a form with the enter key?

I currently have a form in ListX that runs fine if you click a link to submit. However, I have users that are always hitting "enter" and expect it to submit. So, I would like to set it up that way if possible.
svedire
Cruiserweight
Posts:107

08/25/2008 2:13 PM Alert 
Hi Radcoder,

You can do this with JavaScript.

If you using an <input> tag, you can use the onkeypress event.

<input type="text" name="fldTest1" id="fldTest1" onkeypress="testClick('fldTest2',event);" />

<input type="button" name="fldTest2" id="fldTest2" value="Test" onclick="Your functions" />

In the Javascript, you can do something like this:

<script langauge="javascript">
function testClick(buttonName,e) {
var key;

if(window.event)
key = window.event.keyCode; //IE
else
key = e.which; //firefox

if (key == 13) {
//Get the button the user wants to have clicked
var btn = document.getElementById(buttonName);
if (btn != null) {
btn.click();
if(window.event)
window.event.keyCode = 0;
}
}
}

</script>


radcoder1
Lightweight
Posts:22

08/25/2008 11:00 PM Alert 
Can you tell me where each piece goes in the ListX module? For example, does the script need to go in the header or footer specifically?
radcoder1
Lightweight
Posts:22

08/25/2008 11:13 PM Alert 
Also, I am not using INPUT, instead I am using an anchor tag that starts an action to insert the data into the database.

<a {ACTION,save,save,,Message} onclick="return Page_ClientValidate();">CLICK HERE</a>

Does this affect how it works?
svedire
Cruiserweight
Posts:107

08/26/2008 9:22 AM Alert 
Hi Radcoder,

All your html goes in the detail section (if query exists and results are returned) or in the no results section(if query exists and no results are returned) or in the no query section (as the name itself indicates if no query exists). And your JavaScript goes in the Module Header (Settings - Header).

It works pretty much the same way even for an anchor tag..

<input type="text" name="fldTest1" id="fldTest1" onkeypress="testClick('fldTest2',event);" />

Because you are trying to validate you could do something this in the onclick event of the <a> tag..

<a name="fldTest2" id="fldTest2" href="#" onclick="if(typeof(Page_SmartValidate)=='function) if(Page_SmartValidate()) \{{ACTION,save,save,,Message,False}; \}return false;">Test</a>

Be sure to check Include Utilities Javascript and Include validation Javascript udner the General tab.

Hope this helps.

Let me know if you have any further questions.

Thanks,
Sindura
R2integrated
rob7765
Featherweight
Posts:9

08/26/2008 11:47 AM Alert 
Hi, I have been looking for this solution and was just about to ask it here in the forum when I saw this post. I tried it and it will return my results but then it refreshes and clears out my results. It is almost like it is posting twice?

Here is what I have in the FORMAT

<TABLE WIDTH=100% BORDER=0 CELLPADDING=0 class="normal">
<TR>
<TD><input name="fltSample_Keywords" id="fltSample_Keywords" type="text" onkeypress="testClick('tbiFilter',event);" style="WIDTH: 100%;" >
</TD>
</TR>
<TR>
<TD><input type="image" name="tbiFilter" id="tbiFilter" value="Test" border=0 style="CURSOR: hand; CURSOR: pointer;" src='http://dnn.bi4ce.com/[PORTALPATH,System]/Images/search_btn.jpg' onclick="lxFetch(802,0,'');lxModule(802,true);" onmouseover="this.src='http://dnn.bi4ce.com/[PORTALPATH,System]/Images/search_btn_ovr.jpg'" onmouseout = "this.src='http://dnn.bi4ce.com/[PORTALPATH,System]/Images/search_btn.jpg'"></TD>
</TR>
</TABLE>

AND here is what I have in the module header:

<script langauge="javascript">
function testClick(tbiFilter,e) {
var key;

if(window.event)
key = window.event.keyCode; //IE
else
key = e.which; //firefox

if (key == 13) {
//Get the button the user wants to have clicked
var btn = document.getElementById(tbiFilter);
if (btn != null) {
btn.click();
if(window.event)
window.event.keyCode = 0;
}
}
}

</script>


Do you see anything wrong with this?
rob7765
Featherweight
Posts:9

08/26/2008 11:52 AM Alert 
The forum seems to be replacing my URL with the Bi4ce url but you can see what I have.
radcoder1
Lightweight
Posts:22

08/26/2008 11:21 PM Alert 
I think its getting close. I think there is an issue with the validation, however. In the code from svedire, it references "smart validate". The existing code doesn't use smart validate - is there possibly a slightly different way to write it with the validation as shown below?

Here is what I have:

In the html:
<span
id="vCode2val"
controltovalidate="txtval"
text="Required Field"
display="Dynamic"
evaluationfunction="RequiredFieldValidatorEvaluateIsValid"
initialvalue=""
style="color:Red;display:none;">Required</span>


In the footer:
<script>
<!--
var Page_Validators = new Array(
document.getElementById('vCode2val')
);
var Page_ValidationActive = false;
ValidatorOnLoad();

function ValidatorOnSubmit() {
if (Page_ValidationActive) {
return ValidatorCommonOnSubmit();
}
return true;
}
// -->
</script>
radcoder1
Lightweight
Posts:22

08/27/2008 7:10 PM Alert 
I did get this to work - there were actually no changes required to the way it validated. Thank you.
djamell
Lightweight
Posts:17

09/24/2008 7:40 PM Alert 
Mine works for IE 6 and 7 but does not work for Firefox 2 or 3.

Any suggested changes to the Javascript?
bgates
Heavyweight
Posts:197

10/05/2008 12:02 PM Alert 
radcoder1 - Page_SmartValidate does roughly what you've implemented, but it seeks all <span> tags with the "controltovalidate" attribute set, and uses those to build the Page_Validators array. To use this feature, make sure you've checked the Inlcude Validation checkbox under General settings. Otherwise, everything's exactly the same.

djamell - Which aspect doesn't work with Firefox? The keypress or the validation?

Bob Gates
Business Intelligence Force, Inc. (bi4ce)
djamell
Lightweight
Posts:17

10/05/2008 5:06 PM Alert 
Keypress.
djamell
Lightweight
Posts:17

10/09/2008 10:45 AM Alert 
Bump, please. My client has now discovered the problem and is asking me why pressing Enter works in IE but not Firefox.

Thanks in advance.
djamell
Lightweight
Posts:17

10/09/2008 4:50 PM Alert 
Never mind. It's working now.

I neglected to put the javascript in the Module Header. Once I did that, it works fine in Firefox.

Sorry for the false alarm.
You are not authorized to post a reply.
Forums > Bi4ce.Modules.ListX > General > Submit form with enter key



ActiveForums 3.6
Latest Post
 
At R2integrated (formerly Bi4ce), we take support seriously.  That's why we support our customers and DNN community with daily monitoring from our experienced engineering team.  We ask that the first step taken is to read the relevant documentation and support forums prior to submitting any questions that may already be available or have been answered.  We ask that you review the documentation that we provide for our products before posting a question.

The Forums are for our customers to chat, exchange ideas and strategies, and submit feedback.  Please be sure to perform keyword searches for previous related forum responses.

To be helpful when submitting a new item, please include the following: 
  1. DNN Version
  2. Module Version
  3. Admin Log Viewer Information
  4. Environment detail: Operating system, .NET framework version, database and version, IIS version, Browser version (if appropriate)
We always try to respond quickly and monitor the forums daily during business hours (EST).  Occasionally, requests for a specific project requirement may not apply for the free support offered. For project specific support please submit via our Information Request form.

Thank you for using our Forums.

Click here to register for the Forums
 
© 2008 by R2integrated (formerly Bi4ce) | DNN® is a registered trademark of DotNetNuke Corporation