[Last Call] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 168
  • Last Modified:

Attach a Script to a Button

I am able to design basic html websites, but I have no experience how to
attach a piece of script code to a button ...

I have to attach a button to each of the scripts a company provided for a demo ...

Can someone give me the basic syntax to attach the following code sample to run when the
user clicks a button?

<SCRIPT LANGUAGE="javascript1.2" type="text/javascript" SRC="http://testcode.com/Include.aspx?AffID=Test&PageID=GENERICSCRIPTPETEDEMO"></SCRIPT>

Typically this type of script is just added to a html page and it automatically runs when the page
loads ... since I have 13 demos to show I want to just activate the code when the user selects the
one they want to view ...
2 Solutions
assuming your code to be run is encapsulated in the retrived file as
  function clickme() { ... }

then  the button to execute it would be
 <button onClick="onclick();">click me</button>

how about reading a book about HTML basics first?

in your .js file you may have multiple functions defined, select the corrdt function and add it to your button like this:

<input type="button" onclick="myclickfunc()">

your .js file might look like this

function myclickfunc()
   //code here
alert("hello world!");
AEIIAuthor Commented:
I appreciate your replies, but I did accomplish it another method ...
I am disappointed in that a reply to have me read a HTML basic book first was
given ... I prefer to see models and test and play around to better understand the code being performed ... not read someone's idea of how they want you to learn the subject they are considered an expert at ... I need much more kinestetic environments ...

Also I thought this was why I pay for the subscription each year to be able to ask at times some very stupid questions ...

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now