cancel
Showing results for 
Search instead for 
Did you mean: 

OnInputProcessing is called twice by using onclick!?

Former Member
0 Kudos
331

Hi,

i ve following situation:

User can press ENTER or click on a button for submit a form. In order to run a javascript before running in oninputprocessing i m using an input field type button and the eventhandler onclick for clicking on the button, for ENTER I m catching the key code.

The problem is now that the oninputprocssing or submit is called twice if an event is fired. However the second time the eventid is empty. And that s the code:

<testscript fore=document event="onkeyupe()" language="JavaScript">

{

myHandler();

}

</script>

<testscript language="JavaScript">

function myHandler(c_id, in_name){

var key_code = window.event.keyCode;

if (key_code == "27"){

document.all.me.click();

} else if (key_code == "13" || c_id == "en"){

if (document.all.cursor_field.value == 'data-sped_date_input') {

var fn = document.all.cursor_field.value;

var x = document.getElementsByName(fn)[0].value;

var y = check_date(x);

if (false == y) {

return;

}

document.getElementsByName(fn)[0].value = y;

}

if (key_code == "13"){

document.forms["myForm"].elements["we_event"].name = 'OnInputProcessing(ENTER)';

}

else {

document.forms["myForm"].elements["we_event"].name = in_name;

}

document.forms["myForm"].submit();

}

}

</testscript>

<input type="button" id="en" onclicke="myHandler('en', 'OnInputProcessing(ENTER)')" name ="Enter" size="02" value="Eingabe" CLASS="btn" />

Any ideas?

Jens

Accepted Solutions (0)

Answers (2)

Answers (2)

raja_thangamani
Active Contributor
0 Kudos

Try this code..Tested & working fine.,.


<%@page language="abap" %>
<%@extension name="htmlb" prefix="htmlb" %>
<s-cript t-ype="text/java-script">
function checkEnter(e,event_name){
var characterCode;
if(e && e.which){
event = event;
characterCode = e.which;
}
else{
e = event;
characterCode = e.keyCode;
}

if (characterCode == 13)
{
document-getElementById("OnInputProcessing").value = event_name;
document-getElementById("mainform")-submit();
} 
}
</s-cript>

<html><form name = "mainform" >
<input type=text name="empno" value = "<%= empno %>" onKey-Press="checkEnter(event,'Display_User')">
<input type=submit name="onInputProcessing(Display_User)" value="Submit" >
<input type="hidden" name="OnInputProcessing" value="value"/>

</form></html>

Regards,

Raja

Former Member
0 Kudos

Hi,

I'm not sure it will helps, but, who knows?

What browser do you use? I know there are some browsers that trigger the submit form event when clicking an input field type button, so the form is submitted even if the Javascript doesn't do this. So maybe the submission is done twice because of that...

Good luck.