Jump to content

CourseLab and JavaScript


Eve
 Share

Recommended Posts

Hi!I can't finish my GIMP introducing video - there is necessary to write JavaScript. Can anyone help to write such code:20 objects must be hidden and one is showed which user click.I have understand, that I have to define objects OBJ_1 - OBJ_20, then I have to tell that function hide() must all this objects hidden and call function hide(). And OBJ_21 display=show. But how I can this write?Thank you,Eve

Link to comment
Share on other sites

You would give each a unique identifier (id=""), and then use Javascript's DOM to show/hide. Have a link such like the following for each object you want to toggle.

<a href="java script:void(0);" onclick="showhide('THEID')">show object #OBJECT_NUMBER</a>

Then a JS function something like:

function showhide(targetId){   var targetElement = document.getElementById(targetId).style;   targetElement.display = (targetElement.display == "none") ? "block" : "none";}

If you want them hidden by default in JS enabled browsers then toggle them all into display:none; on the page load.EDIT: made my explanation a bit clearer.

Link to comment
Share on other sites

Please show us the HTML page in question. The original text of your assignment would also help.EDIT: That is, if Elliot didn't answer your question. BTW, you can just pass the actual element (this) rather than the id - whether you put the onclick in the HTML or (preferably) the JS.

Link to comment
Share on other sites

You would give each a unique identifier (id=""), and then use Javascript's DOM to show/hide. Have an onclick="showhide('THEID')" in a link, and a JS function something like:
function showhide(targetId){   var targetElement = document.getElementById(targetId).style;   targetElement.display = (targetElement.display == "none") ? "block" : "none";}

If you want them hidden by default in JS enabled browsers then toggle them all into display:none; on the page load.

Is it so, that I have to define every single object with array?
var objektid = new Array();objektid[0] = OBJ_1;

or how I can give each a unique identifier?Every slide have 10-23 objects (balloons, that explain GIMP menu) and define with array means objektid[321]=OBJ_322.

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
 Share

×
×
  • Create New...