How to call button from page activity in script to verify which button clicked ?

Avatar

Avatar
Validate 1
Level 2
Prasanna_Soni
Level 2

Like

1 like

Total Posts

67 posts

Correct reply

2 solutions
Top badges earned
Validate 1
Ignite 1
Give Back
Affirm 1
View profile

Avatar
Validate 1
Level 2
Prasanna_Soni
Level 2

Like

1 like

Total Posts

67 posts

Correct reply

2 solutions
Top badges earned
Validate 1
Ignite 1
Give Back
Affirm 1
View profile
Prasanna_Soni
Level 2

30-04-2021

I have page with 2 buttons based on click of button i have to perform certain task. in Java script i need help to decide on the same, so its very importnat for me to read the button id . I assume it will be something like ctx.buuton_id.click() = True or something similar but dont know and hence need guidence . 

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Boost 3
Level 3
Amit_Shinde
Level 3

Likes

22 likes

Total Posts

17 posts

Correct reply

11 solutions
Top badges earned
Boost 3
Boost 1
Affirm 3
Affirm 1
View profile

Avatar
Boost 3
Level 3
Amit_Shinde
Level 3

Likes

22 likes

Total Posts

17 posts

Correct reply

11 solutions
Top badges earned
Boost 3
Boost 1
Affirm 3
Affirm 1
View profile
Amit_Shinde
Level 3

01-05-2021

Hi @Prasanna_Soni,

 

Sharing sample code. Please try the below logic.


<html>
<head>
<script>
function myFunction(selectedButton){
if(selectedButton=="Button1")
{
// Add javascript Code & 1st transition
document.controller.submit("next", "", "next"); ;
}
if(selectedButton=="Button2")
{
// Add javascript code & 2nd transition
document.controller.submit("next", "", "next2"); ;
}

}
</script>
</head>
<body style="" class="">
<form>
<p>Please click the button</p>
<div class="submit-field"><span>&gt;</span><button id="Button1" onclick="return myFunction(this.value)" value="Button1">Button1</button></div>
<div class="submit-field"><span>&gt;</span><button id="Button2" onclick="return myFunction(this.value)" value="Button2">Button2</button></div>
</form>
</body>
</html>

 

Thanks,

Amit

Answers (1)

Answers (1)

Avatar

Avatar
Give Back 50
Employee
Sukrity_Wadhwa
Employee

Likes

168 likes

Total Posts

930 posts

Correct reply

35 solutions
Top badges earned
Give Back 50
Validate 1000
Validate 500
Validate 250
Validate 100
View profile

Avatar
Give Back 50
Employee
Sukrity_Wadhwa
Employee

Likes

168 likes

Total Posts

930 posts

Correct reply

35 solutions
Top badges earned
Give Back 50
Validate 1000
Validate 500
Validate 250
Validate 100
View profile
Sukrity_Wadhwa
Employee

17-05-2021

Hi @Prasanna_Soni,

Was the given solution helpful to resolve your query or do you still need more help here? Do let us know.

Thanks!