We help IT Professionals succeed at work.

simple javascript not working

Jerry Kroger
Jerry Kroger asked
on
Here's the code involved:

          <script language="javascript">
               function sms() {
                   alert("at sms");  /*this alert does NOT work*/
               }
          </script>

         <input type="checkbox" onclick="alert('at sms call'); sms();" /> <!-- when box is clicked, this alert works...-->

Any assistance will be most appreciated. This is driving me nuts! :-)

Thanks much,
softexecware
Comment
Watch Question

Trenton KnewOwner / Computer Whisperer

Commented:
why are you calling the function and the function's function at the same time?  

What is it exactly this function is supposed to do?

What is returned when you click the button?  "at sms call" or "at sms"?
Jerry KrogerCTO - Founder

Author

Commented:
There are other things that will be added to the function, after it starts to fire.
"at sms call" is returned when the checkbox is clicked.
Then it should fire the function sms(), but that is not happening - and that's the issue
Trenton KnewOwner / Computer Whisperer
Commented:
This appears to work fine...
 <script language="javascript">
               function sms() {
                   alert("at sms");  /*this alert does NOT work*/
               }
          </script>

<input type="checkbox" onclick="sms();" /> <!-- when box is clicked, this alert works...-->

Open in new window

Developer & EE Moderator
Fellow 2018
Most Valuable Expert 2013
Commented:
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JS Bin</title>
         <script>
               function sms() {
                  alert('at sms call');
                   alert("at sms");  /*this alert does NOT work*/
               }
          </script>

</head>
<body>
    <input type="checkbox" onclick="sms();" />
</body>
</html>

Open in new window


http://jsbin.com/joleridito/1/edit
Jerry KrogerCTO - Founder

Author

Commented:
Thanks to each expert!
Both solutions worked.
...and forced the cache to update than my original code started working.
I have changed my settings to check for new versions every time a page loads.
Thanks again,
Jerry
Jerry@softexecare.com