how html button with java script click event with parameter in outsystems?

Hi All,


I am new to outsystems and struggling, kindly guide me how I can achieve the below html code in outssytems, especially button onclick="startButton(event)" 

 <button id="start_button" onclick="startButton(event)">


Thanks in advance for help.

Hello saif,  don't worry :)

You can do like this

1-put the button on your screen and create a client action

2- then move the block javascript and do whatever you want.

If you want to use parameters inside of a block of javascript, you can do like this

1-

2- Then if you want to pass the input you want, you click outside of the block and you can pass whatever you want, even an id from your elements

Kind regards,

Márcio

I have tried this but guide me please how I can pass the event parameter in onclick="startButton(event)"

If you want to pass something inside of the function, you need to create the input parameter on the javascript block and then you pass the event on that parameter.


I have to pass the event parameter in onclick="startButton(event)"

event is actually java script event(click event), I am unable to pass it, see sample code below,

<button id="start_button" onclick="startButton(event)">

See, my javascript is just the basics, so, I am not an expert :D I don't know how to do that now, but you can do it in another way,

putting an event listener, this is just an example

document.getElementById("my_button").addEventListener("click", check_me);

Hello Saif ,

 Agree with Ellakkiya S

Please go through this OML for reference of button and java script used.

 for event

Create event as it is and call that JS it will work

Thanks and Regards,

Akshay Deshpande

TestingPhone.oml

Thanks Akshay Deshpande,

Kindly guide me please how I can pass the event parameter in onclick="startButton(event)"

event is actually java script event(click event), I am unable to pass it, see sample code below,

<button id="start_button" onclick="startButton(event)">


Okay. 

$("id" ).click() pass the Id of container as input to the java script. note to pass id of widget name property must be filled.

may be this will helps you

 Thanks and Regards,

Akshay Deshpande

mvp_badge
MVP

Hi Saif,

Welcome To OutSystems!

For the community to help you better, please mention the Application type (Traditional, Reactive, PWA, Mobile) and also include some additional information related to your case in the post.

Generally, in OutSystems, the button widget does have the OnClick handler as a mandatory field which doesn't give you direct access to the event object. Instead, you can refer to the below-mentioned one of the possible workarounds to retrieve the registered event object.  

For Reactive Web Application: See this sample screen JS_EventDemo

Steps to follow:

  1. Register an onclick handler for the respective button in the Screen OnReady action flow
  2. In the handler function, capture the incoming/registered event object
  3. Hold the event object in a local Object data type variable and use the same wherever it is required

Refer to the attached .oml file


I hope this helps you!


Kind regards,

Benjith Sam

RWALabBtnEvt.oml

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.