How to link external javascript file onclick of button

前端 未结 8 1161
旧时难觅i
旧时难觅i 2020-11-29 20:22

The javascript file is there in Public/Scripts/filename.js. I have a template file in template/form.tmpl.html. Root folder contains Public and template folders

I wo

8条回答
  •  萌比男神i
    2020-11-29 21:03

    By loading the .js file first and then calling the function via onclick, there's less coding and it's fairly obvious what's going on. We'll call the JS file zipcodehelp.js.

    HTML:

    
    
    
        Button to call JS function.
    
    
        

    Use Button to execute function in '.js' file.

    And the contents of zipcodehelp.js is :

    function ZipcodeHelp() {
      alert("If Zipcode is missing in list at left, do: \n\n\
        1. Enter any zipcode and click Create Client. \n\
        2. Goto Zipcodes and create new zip code. \n\
        3. Edit this new client from the client list.\n\
        4. Select the new zipcode." );
    }
    

    Hope that helps! Cheers!

    –Ken

提交回复
热议问题