Jump to content

[SOLVED] declaring functions inside html tags


frikus

Recommended Posts

Is it possible to declare an event handler function  directly inside HTML tags?

Something like this:

 

<select onchange="function() {var $ok='ok';  alert($ok); }">

 

    <option value="1">1</option>

    <option value="2">2</option>

 

</select>

 

It doesn't work,  is there any other way to do this?

Thanks! I didn't know that it could be a function already, JavaScript is really a tricky language.

 

For everyone who is interested, it works correctly in this way:

 

<select onchange="var ok='ok';  alert(ok);">

 

    <option value="1">1</option>

    <option value="2">2</option>

 

</select>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.