Hello,
I have small problem and can't solve it. I am trying to write javascript function inside html file and call it from click button but it does not work. I try both tags:
<script type="text/javascript">
<script language="JavaScript">
I include it at the head tag, at first of body, at end of body, before head. but, does not works!
it called from <input type='button' name='but' onclick="alertx();">
and it just alerting

<script type="text/javascript">
function alertx()
{alert('hi');}
</script>

Any help please.
Thanks,

Member Avatar for diafol

Show the page

<html>

<script type="text/javascript">
function alertx()
{alert('hi'); }
</script>

<head>
<script type="text/javascript">
function alertx()
{alert('hi');}
</script>
</head>

    <body>
        <script type="text/javascript">
            function alertx()
            {alert('hi');}
        </script>
        ..... some inputs ......
        <input type='button' name="x" value='Basic search'  onclick="alertx()">
        ..... some inputs ......
        </body>
        </html>
Member Avatar for diafol
<html>

<head>
<script type="text/javascript">
function alertx()
{alert('hi');}
</script>
</head>
    <body>

        ..... some inputs ......
        <input type='button' name="x" value='Basic search'  onclick="alertx()">
        ..... some inputs ......
        </body>
        </html>

Works for me. You sure js has not been disabled on your Browser?

It does not work for me. but, when I alert here:

<input type='button' name="x" value='Basic search'  onclick="alert('hi');">

it working.

Member Avatar for diafol

sorry can't replicate your issue.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.