Jump to content

Javascript Second Call


Chikwado

Recommended Posts

Some one check this: Javascript second call function, for example: when i click first button to triger a function it displayed, then in that dispayed field another trigerable button are there, I want to call it and dispaly in a div.

Link to comment
Share on other sites

All sorts of problems in these lines...

<scrpt type="text/javascript" src="jquery-1.11.2.min.js"></script><script type="text/javascript" src="myjavascript.js"></script></head><body><header claas="levela">
Link to comment
Share on other sites

This is what am doing here http://chiquado.site90.net/tutorial.html. When you click those navigation bar, It display a page with hyper link. If click those new link it does not goes anywhere. The first navbar is a function and second is a function. The first one work fine but the second one does not.

Edited by Chikwado
Link to comment
Share on other sites

Let me explain to you what I want to do: 1 create a navbar. 2 when you click the navbar it will call a page and dispaly them in aside. 3 page in aside is also a hyper link, if you click the link in aside it call a new page in the section. All these are javacript function.

Edited by Chikwado
Link to comment
Share on other sites

Elements must exist when binding a event handler, you are creating elements with event handlers that do not exist on page load, with such elements you have to identify the element and bind a onclick event to reference the function after creating each elementSimilar to

document.getElementById('created_element_identifier').onclick=function(){Runthis_specific_function()}
A better option would be have all grouping of links in their own containers and hide on load, then unhide them when required, they would then exist page onload and there respective call to a function would be handled by its bound event.
Link to comment
Share on other sites

Can some one help view this code once more.

document.getElementById("demo").onclick=function() {       var stuff = "Hello second call!";       document.getElementById("div2").innerHTML = stuff;                           }                                                          }
When I hit the new link It does not call anything. Edited by Chikwado
Link to comment
Share on other sites

Are you trying to create a closure? You have a function inside a function.

 

--edit--

 

OK, now you have edited it and it should work as long as you call it after the page has loaded. You can do this...

window.onload = init;function init(){ document.getElementById("demo").onclick = handler1;}function handler1(){ var stuff = "Hello second call!";  document.getElementById("div2").innerHTML = stuff;}
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...