Skip to Content
avatar image
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 comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

6 Answers

  • avatar image
    Former Member
    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 comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    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 comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    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 comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    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 comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    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 comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    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 comment
    10|10000 characters needed characters exceeded