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
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">');