Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (9.5k points)

Below is the two javascript functions I have: 

  1. showCountry()

  2. showUser()

I have put them in external ".js" files like below:

  1. <a href="javascript:showCountry('countryCode')">countryCode</a>

  2. <form>

 <select name="users" onChange="showUser(this.value)">

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

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

 <option value="3">Joe</option>

 </select>

</form>

Can anyone tell me how to call these functions correctly?

1 Answer

0 votes
by (19.7k points)

You can do it like below:

<html>

    <head>

          <script type="text/javascript" src="path/to/script.js"></script>

          <!--other script and also external css included over here-->

    </head>

    <body>

        <form>

            <select name="users" onChange="showUser(this.value)">

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

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

               <option value="3">Joe</option>

            </select>

        </form>

    </body>

    </html>

Interested in Java? Check out this Java Certification by Intellipaat. 

Browse Categories

...