Skip to Content
author's profile photo Former Member
Former Member

update radioButtonGroup selection on inputfield selection

Hello.

We have the following search form -

=============================================

Search by :

<radio button1> term1 ______________

<radio button2> term2 ______________

<radio button3> term3 ______________

<Submit>

=============================================

(where ______________ represents an input field)

The user can only search by one of those options at a time.

our need is to set the selected radio button automatically, when the user sets focus to one of the input fields, i.e. somehow, fire a clientEvent on the input field's onFocus, and that client event needs to update a certain selection in the radio button group.

can that be done using htmlb ?

Add a comment
10|10000 characters needed characters exceeded

Related questions

6 Answers

  • author's profile photo Former Member
    Former Member
    Posted on May 21, 2004 at 07:28 AM

    There is unfortunaltly no api for adding an onfocus event to the inputfield in htmlb.

    However, you can assign onfocus event handlers to elements using javascript.

    I've made a small example which you can use as a basis (need to extend it to read htmlb ids)

    <script>
    //methods called when an event has occured
    function handleInputClick1(){
    myForm.myRadio[0].checked=true;
    }
    
    function handleInputClick2(){
    myForm.myRadio[1].checked=true;
    }
    
    </script>
    
    <form id="myForm">
    <radio>
    
    </radio>
    <input type="radio" name="myRadio" id="myRadio" value="1">1
    <input id="input1" type="text" value=""><br>
    <input type="radio" name="myRadio" id="myRadio" value="2">2
    <input id="input2" type="text" value="">
    <input type="submit">
    </form>
    
    
    <script>
    //code which assigns the event handlers
    var inputField = window.document.getElementById("input1") ;
    inputField.onfocus= handleInputClick1;
    
    var inputField2 = window.document.getElementById("input2") ;
    inputField2.onfocus= handleInputClick2;
    </script>
    

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 23, 2004 at 07:35 AM

    Hi

    Though it was a little disappointing to learn there is no API for adding an onfocus event to the inputfield in htmlb, it was very important to receive that information, as now i know not to focus my efforts in that direction.

    As you mentioned, in order to use the javascript workaround you have suggested, i need to dynamically find the IDs of both the radio buttons and the input fields.

    I have noticed that though i am assigning my htmlb components with a meaningful ID (like "orderNo" the actual input field in the final html source has some id like "htmlb_236_htmlb_219_5".

    Can you please refer me to a documentation explaining how to get the ids of htmlb components ? (or add a small example) ?

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 23, 2004 at 08:59 AM

    hi

    i found this link in some of the other posts you have made

    http://devnetmedia.sap.com/html/submitted_docs/htmlbManuals/javascriptapi_dev.html

    when i tried to apply it, i got an error saying "Method setJsObjectNeeded(boolean) not found in class com.sapportals.htmlb.InputField"

    i checked in https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sapportals.km.docs/documents/a1-8-4/htmlb api documentation, and indeed there is no such method in the InputField class...

    can you explain this discrepancy ?

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 23, 2004 at 09:12 AM

    seems like using the HTMLB JavaScript API (http://devnetmedia.sap.com/html/submitted_docs/htmlbManuals/javascriptapi_dev.html) is only possible in EP 6.0.

    is that correct ?

    We are still using EP 5 SP 5

    Thanks

    zach

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 31, 2004 at 09:12 AM

    seems like there is a very good solution to this problem, and it works in EP 5.0 as well :

    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sapportals.km.docs/documents/a1-8-4/accessing htmlb-created html elements with javascript

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 01, 2004 at 01:05 AM

    I replied to someone on this forum with some example code of how to access HTMLb via javascript. This is for a radio button group, but in theory, it could be used for any Javascript element (checkboxes, inputfield etc).

    radio-button-group-client-side-javascript

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.