troubleshooting Question

Seperating code from presentation

Avatar of NewWebDesigner
NewWebDesigner asked on
JavaScript
2 Comments2 Solutions135 ViewsLast Modified:
I have code where I am trying to seperate content from presentation:

<td><input type="text"  name="input2" id="input2" onKeyUp="insertPicture(this.value, 'pic2', 'picUrl2', 'warning2', 'ISBN2');"/></td>
           <td><input type="text"  name="input3" id="input3" onKeyUp="insertPicture(this.value, 'pic3', 'picUrl3', 'warning3', 'ISBN3');"/></td>
           <td><input type="text"  name="input4" id="input4" onKeyUp="insertPicture(this.value, 'pic4', 'picUrl4', 'warning4', 'ISBN4');"/></td>

I don't want any Javascript mixed with my HTML.

I came up with something like this:
window.onload = initPage;

 function initPage() {

document.getElementById("input1").onclick = insertPicture('pic2', 'picUrl2', 'warning2', 'ISBN2')

}

function insertPicture(a, b, c, d) {
	window.alert(a);
}

Of course, this code runs when the page loads and not when on onclick.  Any idea how to get it to run onclick?
ASKER CERTIFIED SOLUTION
Eyal

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros