Prototype.js Hide/show With Variable Html Elements?
May 27, 2009
I have been staring at this problem for too long and most likely missing a simple solution so I hope somebody can take my blindfold off and show me the way The markup (which comes from a CMS and I cannot change it) I am working with is akin to:
<div id="faq">
<p><strong class="open">FAQ 1</strong></p>
<p>FAQ 1 content lorem ipsem lorem ipsem ad infinitum</p>
[code]....
Notice how the second fo 3 FAQ sections has 2 paragraphs under the 'trigger' rather than 1? Therein lies my problem, because what I am doing with prototype.js is:
1.) Loop through page and collect all <p>'s
2.) do a .each iteration and attach an onclick event on $$('p strong.open') - assume this node for each iteration is now var 'trigger'
3.) run Element.hide() on trigger.next()
4.) in the onclick event, run Element.show() for trigger.next()
- If you are still following so far - my problem is that next() only shows/hides one single element and that is the <p> holding the content - which is fine except when there are 2 or even more <p>'s with content I need to act on. I;ve experimented with nextSiblings and adjacent() and I end up with too many nodes - basically every <p> in the entire document. I just want 'hide all P's after the trigger P up until the next p > strong.open
View 3 Replies
ADVERTISEMENT
Mar 22, 2010
I'm learning how to use Javascripts and using Prototype framework by following a step by step tutorial from a book. Unfortunately when I stepping through the following code:[code]
View 8 Replies
View Related
Apr 27, 2010
I have 3 divs that contain radio with labels and beneath each radio button I would like to show/hide a form based on whether the radio is selected or not.
Code idea:
So if the radio1 input is selected this would show form1. Selecting radio2 input would hide any other forms (form1, form3) and show form 2 etc.
View 1 Replies
View Related
Mar 14, 2010
I have a page I am working and I am having some trouble with: I need to show and hide areas based on a radio selection. I initally started using the show / hide feature in Jquery but the problem is the elements need to be removed but then put back if the user selects the radio buttonagain as it has form elements that have validaion on them. The validation is still trying to validate the form elements becuase they are still on the page but just not showing. This is the radio group the user makes the selection from:
<input name="terms_usr" type="radio" id="terms_usr_1" value="1"/>
<label for="terms_usr_1">Credit Card</label>
<input type="radio" name="terms_usr" id="terms_usr_2" value="2"/>
<label for="terms_usr_2">C.O.D</label>
[Code]....
View 3 Replies
View Related
Nov 4, 2006
I have some nested lists that I am trying to clean up. What I am wanting to do is to be able to click an item in the outermost list (the catagory), and have it show the appropriate inner list (the subcatagory). I have it working in FireFox, but IE is not working. Code:
View 2 Replies
View Related
Jun 11, 2005
I'm working on a form that hides/shows certain elements when certain things are selected.
In the file I'm working with, when you select the "problem" radio button, the "problem" drop down menu appears. When you select the "request" radio button, the "request" drop down menu appears
Now, when I try to make a selection from the "problem" drop down menu, nothing appears like it should (Computer, Monitor, Printer, and AVPeriph are the active ones). Everything stays hidden.
With each of those 4 selections, a table element should appear. Any ideas to what the problem is? I'm assuming it's the javascript since I don't know it too well.
View 8 Replies
View Related
Nov 5, 2010
I'm trying to figure out a small javascript question. I have certain elements in my pages that I want to show or hide if the user has javascript disabled. [code]...
View 1 Replies
View Related
Nov 6, 2007
I am trying to show/hide all the elements with a specific id ....
View 1 Replies
View Related
Jan 11, 2011
I have a page that is generated using php. Below, the pdf newsletter for each month is embedded directly into the page. What I want to do is have some javascript that when the link for a month is clicked, the embedded pdf expands below and when the user clicks on another month, that newsletter is hidden then the one they clicked on gets displayed; so only one newsletter is displayed at a time.
View 3 Replies
View Related
Jun 16, 2011
$('a.showContent').click(function(e) {
e.preventDefault();
$(this).each(function(i) {
$(this).parent().parent().find('.hide').slideDown();
[code]...
is also not doing it..how do I hide elements with same link that I used to show them?
View 4 Replies
View Related
May 5, 2010
oving jQuery at the moment, and have sort of hit a hiccup with showing and hiding specific elements with the same class. My idea is, what if I wanted to add a little button to show and hide the contents of a specific comment on a forum post, or blog, whatever. This would be easily done with id's but I'd like to just apply a class to each one of them and allow them to hide their contents. Here is the javascript and html as an example of what I am talking about.
[Code]...
View 2 Replies
View Related
Sep 9, 2010
i've got a question. I would like to show childlists in a sidebar which have less than 2 elements in it, and hide childlists which have more 4 elements in it.this is what i got til now:
$('.sf').children('li').children('ul').length <= '2'){
$('.sf').children('li').children('ul').show();
}
but with this code, all childlists will be shown.
View 2 Replies
View Related
Sep 9, 2005
I'm doing a page w/lots of divs that I set to visibile or hidden dynamically using getElementById.. the divs are all forms... sometimes elements in a hidden form show thru on a visible form.. how can I fix this..
View 5 Replies
View Related
Oct 14, 2005
How can i do this i already have a function to show/hide elements with one link but how can i show/hide multiple elements
Here is the script:
function obj_ref(object)
{
if (document.getElementById)
{
return document.getElementById(object);
}
else if (document.all)
{
return eval('document.all.' + object);
}
else
{
return false;
}
}
function obj_toggle(object, open_close, open_text, close_text)
{
var object = obj_ref(object);
var icone = obj_ref(open_close);
if( !object.style )
{
return false;
}
if( object.style.display == 'none' )
{
object.style.display = ''
icone.innerHTML = close_text;
}
else
{
object.style.display = 'none'
icone.innerHTML = open_text;
}
}
View 4 Replies
View Related
Aug 4, 2010
how one can show and hide a div element using a pulldown menu. i need the different selections in the pulldown menu to show hidden DIV elements on the page. this will be used in a system where i only have access to the template, so the only approach i can use is jquery. how to change it for the specific selectors i need.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
[Code].....
View 2 Replies
View Related
Nov 13, 2010
I've tried to find a stright forward script which show/hide specific form fields based on a selected option. I've seen many online but non of them was working with me without the need of some coding or tweeks. Does anyone here have such script?
View 4 Replies
View Related
Jan 26, 2009
I got a table.Each row has a list of statuses.If status == yes, then several elements will be shown in the rowif status != yes, then hide those elements.Im not sure if I have made a good solution, but it seem to work ok (opera9.6, ff2, ie7)The status selector passes on a unique rowid, and itself. This way the js function can get the row, and the status of the selection. Then toggle various elements in that row.Only annoying thing is the way row elements are named and found. It kinda have to rely on some hard coding, but its ok I guess.Im not sure if its possibel to just call toggle( this ), and that way get to the elements in the row.
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
[code].....
View 7 Replies
View Related
Jan 27, 2011
I have a HTML document with form. The form has several radio buttons. I want different elements of HTML (including <input> elements) to appear when each radio button is selected. Also, it is intended to show only those elements for a specific radio button. For example, if i select RB1, it shows me element div 1 and hides all others. If i select RB2, it hides element div 1 and shows element div 2, et cetera. So far it works fine with .style.visibility = 'hidden' and 'block'. Now, here comes the problem - each element appears below the previous element, they appear as they are in the HTML, no matter if i show the previous one. It looks pretty bad, because element positions are jumping as i select different radio buttons. How do i keep them in the same level, at the same position?
View 3 Replies
View Related
Jan 28, 2010
I have a multipage form. I can put data entered in hidden form elements from previous pages. I want to show or hide table rows depending on this data value.
For example, I collect a list of names in first form, but if some names are blank I dont want to show the table row associated with that name to collect more data.
I have seen loads of code to toggle rows but cant find any which shows me how to toggle on a variable.
View 2 Replies
View Related
Feb 13, 2006
I am setting up a contact form, and want to have a drop down box with a handful of options. Clicking one option should display fields to input username & password, whereas all others will not. So far, I've tried and (replacing 'none with 'block' for the option that is supposed to show the input fields) but neither does what I need it to. I'm fairly new to javascript, just muddling my way through with the aid of tutorials.
View 2 Replies
View Related
Sep 30, 2010
Looking for a way to show/hide the parent of a class of elements:
Code:
But FF is giving the error message "'elP.parentNode' undefined". Something I'm not getting.
View 2 Replies
View Related
Feb 3, 2010
I want to get javascript to show or hide a row in a table depending on whether a value is held by a variable collected in a mulitple part formmail. If only 1 adult fills in their name on the earlier form there is no need to show the row which asks him to agree to membership on a later form page. This is what Ive got so far<form name="frm3" method="post" action="bookingscript.php">
<input type="hidden" name="adult2fn" value="$adult2name" />
<script Language="JavaScript">
var name1 = document.frm3.adult2fn.value;
if(name1 =="")
[Code]....
View 7 Replies
View Related
Aug 23, 2011
I was just wondering whether there is a way to hide an element on another page after clicking on a button?Basically, I have a login page, and for testing purposes, I want it so when you click a button, it runs some javascript in a file called ajax.util.js, and I have a jQuery file attached to the HTML file as well URL..., and I am using Google App Engine, which im not sure whether thats relevant. I tried using the show and hide functions provided by the jQuery file, but no luck, i want to hide an element which is a link with ID admintools. I have also tried getting the element by ID and changing the display style to none and hidden but still no luck. Im not sure whether its only possible to hide elements in the login.html page.
What I want it to do basically is click on the submit button in the login page, it will then run a javascript function which redirects you to index.html (which i am doing using window.location), and then hides an element in the index.html page (id=admintools).
View 1 Replies
View Related
Mar 17, 2011
I have a set of radio buttons on my pricing page:
And a corresponding text_field input element div I'd like to display based on which radio button the user selects:
When the page loads, I'd like to see:
When the user clicks on a (different) radio button, or clicks one for the first time, I'd like whichever div is currently showing to be hidden, and the newly selected one to be shown.
Right now I have jQuery code at the bottom of my page that looks like this:
For each of the four options.
When the page loads, the correct div is shown, and when I select a new button, the new div is shown, but the already showing one isn't hidden.
I've read some posts that suggest using change() instead of click(), but others indicate that's problematic in IE.
View 1 Replies
View Related
May 19, 2011
I'm trying to implement a show/hide toggle for each users profile field in the view body topic of my forum.
I found this thread here @ sitepoint which is close to what I'm working on, but the code I'm working with is different.
What I need are some changes to the JS so that each show/hide works independently, not just the first instance of the show/hide.
How do you call this HTML
Code:
With this JS to be independent?
Code:
I know that this would have bits of " $(function() and $(this) " but that's about all I know...
View 8 Replies
View Related
Mar 1, 2010
I am having some jQuery troubles whereby I have some jQuery that toggles an 'Other' HTML input field and associated label when a user selects the value Other from a HTML select drop down. I have this working for one field but the application I am building has increased in scope whereby there may be multiple instances of members on one page so the Other option will be there multiple times. At the moment if a user selects Other from one drop down all Other input fields show. How do I make this exclusive without repeating the jQuery for the separate instances?
// Show/Hide 'Other'
$(document).ready(function() {
$('.jOther').hide();
$('.jTitle').change(function() {
var $index = $('.jTitle').index(this);
alert($index);
if($('.jTitle').val() != 'Other') {
$('.jOther').hide();
} else {
$('.jOther').show();
window.location.hash = 'Other' + $index;
}});
});
<td>
<select id="title" class="inlineSpace jTitle">
<option value="Please select">Please select...</option>
<option value="Mr">Mr</option>
<option value="Mrs">Mrs</option>
<option value="Ms">Ms</option>
<option value="Miss">Miss</option>
<option value="Dr">Dr</option>
<option value="Other">Other</option>
</select>
<label for="other" class="inlineSpace jOther">Other</label>
<input type="text" class="text jOther" name="other" id="other" maxlength="6" />
</td>
View 1 Replies
View Related