ollie007 Posted June 7, 2009 Share Posted June 7, 2009 any prototype experts? i would like to add extra input fields with one initially, like adding extra poll options Quote Link to comment Share on other sites More sharing options...
RichardRotterdam Posted June 7, 2009 Share Posted June 7, 2009 what do you have so far? It seems you need to look into the following from the prototype manual: [*]event for triggering an event on a click to add an element [*]element for creating a new element [*]insert for inserting the new element Quote Link to comment Share on other sites More sharing options...
ollie007 Posted June 8, 2009 Author Share Posted June 8, 2009 well all i have done is $('selector').show() and .hide() Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted June 8, 2009 Share Posted June 8, 2009 Well now it's time for you to learn a new method called insert. Dj Kat already posted the link to it. I suggest reading it. Quote Link to comment Share on other sites More sharing options...
ollie007 Posted June 8, 2009 Author Share Posted June 8, 2009 i have used the display:hidden and then show, but its still in the page source. How can i hide the hidden element unless event fires, so whether the javascript is enabled or people looking at the page source. How can i hide it securely unless the event is fired? Quote Link to comment Share on other sites More sharing options...
ollie007 Posted June 8, 2009 Author Share Posted June 8, 2009 Before $('foo').observe('click', respondToClick); function respondToClick(event) { var element = Event.element(event); element.addClassName('active'); } After $('foo').observe('click', respondToClick); function respondToClick(event) { var element = event.element(); element.addClassName('active'); } what do these 2 functions do?? 1. The first one changes the classname, is it instantaneous? 2. If so, then the second one when fired cant find any valid elements? (My bad its the ID aint it LOL) 3. How can i add show() and hide()? like this? element.show('myHiddenClass'); Quote Link to comment Share on other sites More sharing options...
RichardRotterdam Posted June 8, 2009 Share Posted June 8, 2009 let me simplify that. the following code will put a onclick event on an element with the id foo. Or in other words when you click the hyperlink with the id foo it will alert "chuck norris" <script> //wait for the dom to be loaded (not sure if it has a ready method not a prototype pro) document.observe("dom:loaded", function() { //add a onclick event to the foo link $('foo').observer('click',function(){ alert('chuck norris'); }); }); </script> <a href=# id="foo">click me</a> the following does the same only that the above method is the unobtrusive way. <a href=# onclick="alert('chuck norris')">click me</a> as for hide() and show(). You don't need those you need to inject something new now show or hide something. Quote Link to comment Share on other sites More sharing options...
ollie007 Posted June 9, 2009 Author Share Posted June 9, 2009 what does "alerting chuck norris" do? exactly LOL showing and hiding an element with some action is something i am looking to do example here http://iwitness.x24hr.com/judicial_corruption/index.php?/forum/2-kangaroo-courts-world-wide/ the top blue bar starting with "subforums"; i would like to remove it completely when there is NO data, like it is here so basically i am showing and hiding an element. Injection sounds like AJAX which i am leading onto Quote Link to comment Share on other sites More sharing options...
RichardRotterdam Posted June 10, 2009 Share Posted June 10, 2009 Your original question i would like to add extra input fields with one initially, like adding extra poll options Your last question showing and hiding an element with some action is something i am looking to do This confuses me which one is it. Hiding and showing an element or inserting a new element? These are two different things what does "alerting chuck norris" do? exactly LOL If you're in luck it might summon him right in front of you and instantly solve your problem with his amazing powers. If not then it will just alert Chuck Norris Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.