Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Use onClick in g_form.addInfoMessage

sajan0192
Giga Expert

1) g_form.addInfoMessage("<input type=button onClick=alert('from button') value='click here'>");

2) g_form.addInfoMessage("<input type=button onClick=return myFunction(); value='click here'>");

function myFunction()

  {

  alert('in function');

  }

onclick function is not working!

Please help!

2 REPLIES 2

Mujtaba Amin Bh
Mega Guru

Why are you using info messages for creating buttons. Why not UI actions?



Anyways:



Try



g_form.addInfoMessage("<input type=button onClick=javascript:alert('from_button'); value='click here'>");


Brad Tilton
ServiceNow Employee

Hi Sajan,



I can't remember whether field messages actually support this and I agree that it shuold be in a ui action. What is the purpose of the click alert?



I would try the following syntax though where you're escaping quotes and onclick is all lowercase:



g_form.addInfoMessage('<input type="button" onclick="alert(\'from button\')" value="click here">');