View Full Version : run script EVENT="onclick()" on all browsers
crmpicco
10-27-2005, 04:02 PM
<!-- RUN CHECK SELECTION JS: Button in Header -->
<SCRIPT ID="script" FOR="submit_button<%=uniqueCount%>" EVENT="onclick()">
javascript: return chkSel('<%=leg1%>','<%=leg2%>','<%=leg3%>','<%=uniqueCount%>');
</SCRIPT>
is there any way of running this code (by changing it?) on all browsers? It only works on IE, MX and DN.
Picco
VortexCortex
10-27-2005, 06:13 PM
Seems like you're using an HTML editor of some type. Make sure your editor is supports the browsers you wish to target.
Calling a function and passing a value to that function via onclick is very simple.
This code will run in any javascript capable browser.
<html><head><title>Click Me</title></head><body>
<button onclick="count += 1; myFunction(count);">Click This Button</button>
<script type="text/javascript">
var count = 0;
function myFunction(i){
var plural;
if (i != 1) plural = "s.";
else plural = ".";
alert("You've clicked the button " + i + " time" + plural);
}
</script>
</body></html>
Notice that the onclick attribute can contain multiple commands. Think of it as if the contents of the onclick attribute will be called via eval.
Note: the onclick attribute can be used for input elements as well
<input type="button" value="Click Me" onclick="count += 1; myFunction(count);">
The above code could replace the button element in the first code example and produce the same results.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.