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 ...
AEIIAsked:
Who is Participating?
 
ahoffmannCommented:
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?
0
 
mrkarrCommented:

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!");
}
0
 
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 ...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.