Jump to content

Prototype experts? multiple forms input


ollie007

Recommended Posts

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?

Link to comment
Share on other sites

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');

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 ;)

 

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.