cancel
Showing results for 
Search instead for 
Did you mean: 

How to get HTMLB button id using javascript?

Former Member
0 Kudos

Hello experts,

I am trying to get the generated HTMLB button id by using javascript only and so far what my script could only do is getting the HTMLB input field object. Is there a method that can give me the genereated HTMLB button id that i can use?

Here is my code snippet:


....
            var funcName = htmlb_formid + "_getHtmlbElementId";
            func = window[funcName];
            var inputfield = eval(func("INPUT_FIELD"));
            alert(inputfield.id);
....

In my code above, inputfield.id seems to be not working so the alert message is not shown. I've tried using inputfield.getId() and inputfield.id() but none of those are working. I am trying to find javascript documentations regarding HTMLB to find out all available methods that I could use. Unluckily did not found anything.

Please help me

P.S. Btw, I could not use the IPageContext.getParamIdForComponent(..) because the HTMLB button is not part of the page context. The button is on the parent window of my pop-up.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello Carlos,

To get the id of the HTMLB element this is the code/syntax that is used. These two lines of code are

standard and will have to be there in the JavaScript Function:

var funcName = htmlb_formid+"_getHtmlbElementId";
func = window[funcName];
var <b>HTMLBElementId</b> = eval(func("<b>idOfHTMLBElement</b>"));

For the UI elements to be capable of client side eventing, the jsObjectNeeded attribute of the UI element

must be set to true, e.g.


<hbj:button
    id="Button"
    text="Submit"
    width="100px"
    tooltip="Click to Submit"
    onClientClick="Test()"
    disabled="false"
    <b>jsObjectNeeded="true"</b>/>

You will find the JavaScript API for some of the UI elements at the following <a href="http://help.sap.com/saphelp_nw04/helpdata/en/43/067941a51a1a09e10000000a155106/frameset.htm">link</a>:

Bala

Former Member
0 Kudos

Hello Bala,

I have tried using your code but still got the problem. I alerted the variable HTMLBElementId and got "[object Object]". Instead of the generated id of HTMLB.

Thanks,

Carlos

Former Member
0 Kudos

Hello Carlos,

Just curious., as to why you need the UI element ID?, because most of the validations could be done without knowing the explicit ID of a UI element.

I guess you've already reffered the link I've mentioned in my previous reply. However, refer this one for a detailed account on validation part. This document gives a BIG picture on client side validation.

<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/94e976d3-0801-0010-92a0-c0725f115860">Form Validations Using JavaScript HTMLB</a>

Bala

Former Member
0 Kudos

Hello Bala,

Ok, first of all I'm sorry if I didn't inform you the reason behind why I need the explicit ID of a HTMLB button and thank you for giving me the link

Actually the thing that I really want to know is the Object ID of the HTMLB button, because I need to pass that value to "function htmlbSubmit(elem,eventType,formID,<u>objectID</u>,eventName,paramCount,param1,param2,param3,param4,param5,param6,param7,param8,param9)". After some investigations that I made, I realized that the Object ID is part of the HTMLB button generated ID (saw it by viewing the page source). So, if I have the explicit ID then I can get the Object ID from it.

Thanks for the help.

Regards,

Carlos

Answers (0)