on 04-06-2005 2:47 PM
How do I submit an HTMLB form using javascript.
document.forms[formId].submit();
works and it seems to refresh the page after submit but it doesnt call the event that is triggered when the htmlb submit button is triggered(which is what i want to do actually).
I read a post which used this
htmlbSL(this,2,'SUBMITVALUES:SendButtonClicked')
but this too didn't work. error - 'Object not defined'
here is htmlb submit button definition
<hbj:button id="btn_update" text="Update" tooltip="Update Specification" onClientClick="validate()" onClick="SendButtonClicked" width="100" design="EMPHASIZED"/>
Any ideas?
Hi Siddartha,
Add the following lienes to your<b> validate</b> function in your javascript. Paste it the way i am sending you. don't change anything.
var form = document.all(htmlb_formid);
form.submit();
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Prakash,
While your code correctly works it has the same effect as
document.forms[formId].submit();
I do not want to submit the form from the validate() method but from a KeyEvent
document.onkeypress = function (evt) {
if (!evt && window.event) {
evt = window.event;
......
....
//Submit form here
}
}
no i am not getting any errors when i do a form.submit()
but the problem is that when the form submits to the dynpage it doesnt call any backend event, it goes to PBO directly.
so i guess there should be some way to trigger a backend event from javascript. the event that is triggered when i click the submit button is onSendButtonClicked and thats because the submit button is defined as
<hbj:button id="btn_update" text="Update" tooltip="Update Specification" onClientClick="validate()" onClick="SendButtonClicked" width="100" design="EMPHASIZED"/>
if i want to "simulate" the click on submit button, how do i do that?
Some one mentioned in another post about this HTMLB method
htmlbSL(this,2,'SUBMITVALUES:SendButtonClicked')
which makes perfect sense since it should call the onSendButtonClicked event in the dynpage. For some reason this doesnt work for me.
Take a look at the following code. This is your solution except for <b>control + S</b> part.
PS: Thanks for the points in advance if it works out for you.
<%@ taglib uri="tagLib" prefix="hbj" %>
<%@ page import = "com.sapportals.htmlb.enum.EventTrigger" %>
<%
String buttonid = "";
%>
<hbj:content
id="myContext">
<hbj:document>
<hbj:documentHead
title="test">
</hbj:documentHead>
<hbj:documentBody>
<hbj:form
id="simpleForm">
<hbj:inputField
id="InputName"
type="string"
maxlength="100"
value="Your name here"
jsObjectNeeded="true">
<%
InputName.setClientEvent(
EventTrigger.ON_KEYDOWN,
"Submit_Event()");
%>
</hbj:inputField>
<hbj:button
id="SubButton"
text="Submit"
tooltip="Sends your info"
onClick="onClicked"
width="30px"
design="EMPHASIZED"
jsObjectNeeded="true">
<%
buttonid = myContext.getParamIdForComponent(SubButton);
%>
</hbj:button>
</hbj:form>
</hbj:documentBody>
</hbj:document>
<script
language="javascript">
function Submit_Event() {
var src= window.event.srcElement;
k = window.event.keyCode;
if (k == 13) {
// enter key pressed
document.all.<%=buttonid%>.click();
}
}
</script>
</hbj:content>
User | Count |
---|---|
85 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.