Show - Hide Dropdown - Script To Work In Multiple Select Fields?
Jun 26, 2009
I am using the following script on one of my pages (script comes from [url]:
Code:
The script works great, BUT I need to use it in 2 different areas of the same form. It only works on an id="selectMenu" and of course I cannot have more that 1 id.
How can I get this script to work in multiple select fields? (at least more than 1)
View 4 Replies
ADVERTISEMENT
Jan 30, 2009
Basically, I have written an application that runs a report based on a certain amount of parameters, one of which being date. So, the date selection is a <select></select> dropdown menu and it has the usual in it, today, yesterday, this week, last week etc. The problem is I need it to have a 'Custom' selection to run reports for custom dates. When 'Custom' is selected in the dropdown menu, two text boxes appear underneath with YYYY-MM-DD watermarked in them. I have assembled enough code from around the web to get this to work and it works fine, the problem I have is that when the user clicks off the 'Custom' option and on to a different one, I need the textboxes to disappear again.
Here is the code I am using:
<script type="text/javascript">
function showhide(divid){
thediv = document.getElementById(divid);
if(thediv.style.display== 'none' ){
thediv.style.display='block'
}else{
thediv.style.display='none'
}} .....
View 3 Replies
View Related
Apr 12, 2010
How do i get a dropdown menu to hide/show a textbox and a label control ? in a asp.net page
Here is my code:
View 3 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
Oct 10, 2011
I'm using a bit of Javascript to display content based on the dropdown selection:http://jsfiddle.net/mcgarriers/wjLXk/However, I would like it when the user selects "show two" that it shows the 2 div elements rather than specifically div2.And for "show three" it would show all 3 divs.
View 2 Replies
View Related
Dec 5, 2010
So I am trying to hide content and show it when selected with a select box. The first select box works fine no problems.
However I added a second one with two options, and it will not work at all. If I use the same name it messes up, and if I make a new name, it does nothing at all.
ShowNext function is the new one I added that doesn't work.
<script type="text/javascript">
function ShowReg(op) {
document.getElementById('public').style.display='none';
document.getElementById('alliance').style.display='none';
[Code]....
View 13 Replies
View Related
Jul 24, 2011
Show/hide table rows via select menu choices - And I changed my Javascript up a little so that I would have an easier time remembering it.Here are the codes:
HTML
<table cellspacing="5" cellpadding="5" border="0">
<tr>
<td><strong>Request Service:</strong></td>
<td><input type="radio" value="Website Design" />
[code]....
View 4 Replies
View Related
Sep 27, 2010
I am using jquery with the cookie plugin and I have multiple image buttons that can hide/show multiple elements. My question is how can I add a cookie to this code to remember whether each separate element is opened or closed?
The code,
$(document).ready(function() {
// choose text for the show/hide link - can contain HTML (e.g. an image)
var showText='<div class="expanddown"></div>';
var hideText='<div class="expandup"></div>';
// initialise the visibility check
var is_visible = false;
// append show/hide links to the element directly preceding the element with a class of "toggle"
$('.toggle').prev().append('<a href="#" class="togglelink">'+hideText+'</a>');
// capture clicks on the toggle links
$('a.togglelink').click(function() {
// switch visibility
is_visible = !is_visible;
// change the link depending on whether the element is shown or hidden
$(this).html( (!is_visible) ? hideText : showText);
// toggle the display - uncomment the next line for a basic "accordion" style
//$('.toggle').hide();$('a.toggleLink').html(showText);
$(this).parent().next('.toggle').slideToggle('fast');
// return false so any link destination is not followed
return false;
});
});
HTML,
<a class="togglelink" href="#"></a>
<div class="toggle">
Content
</div>
View 6 Replies
View Related
Feb 2, 2009
Ive searched this forum for a simple solution to this. I want have a drop down of countries. Only if USA is selected, it shows states, otherwise it is hidden. I have a function which is 'trying' to write the state dropdown to an empty span.
Code HTML4Strict:
<script>
function test(){
document.usstate.write("<select name='state'><option value='' selected>--</option><option value='New Jersey'>New Jersey</option><option value='New York'>New York</option><option value='California'>California</option></select>");
[Code]....
View 16 Replies
View Related
Feb 16, 2009
I've been trying to show/hide something if one of some different options is selected in a dropdownmenu.
This is the code I've landed on so far:
Usually I would place the script in the head tags, but for some reason div2 shows if I do that.
View 3 Replies
View Related
Mar 23, 2011
I have a drop down selection where it shows and hides form inputs depending on selection. When the page loads it shows the drop down selections with no form inputs. After user selects drop down it shows the form fields. It works great but I want it to show the same form fields after the user hits the submit button which submits the page to itself. It currenlty goes back to the default selection list and doesnt show any of the form fields. Basically it hides all the form fields after the user hits submit button. How do I make it keep the last shown form fields after the user hits the submit button?
test3.html looks like this:
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Show/Hide</title>
<script type="text/javascript">
[Code]...
View 17 Replies
View Related
Apr 24, 2010
ive been racking my brain looking for a code solution for this....im a html and css pro....and a javascript heres what im tryna do....i have a form...that has a <option> in it for 6 dropdown options.... in one of those possible options.. when SELECTED...i want the div layer that i currently have under it...to appear and i cant seem to figure it out....heres my code in its entirety i want budget div...to appear when the option website design is selected
[Code]....
View 2 Replies
View Related
May 4, 2011
I'm trying to use jquery to hide some contents in a for statement but is not working. Here is the code
if( $total_attachments > 0 ) {
for ($i=0; $i < $total_attachments; $i++) {
//output div and image in it
echo '<div class="pictures_entry">';
echo '<a href="'.$attachments[$i]["location"].'" title="'.$attachments[$i]["title"].'" rel="prettyPhoto[gallery]"><img src="'.$attachments[$i]["location"].'" width="128" height="120" alt="'.get_the_title().'" /></a>';
echo '<div id="pictures_entry_name_'.$i.'">';
echo '<h6>'.$attachments[$i]["title"].'</h6></div>';
echo '</div>';
}}?>
I want to hide the pictures_entry_name_'.$i. and when a user clicks on a picture <a href="'.$attachments[$i]["location"].'" title="'.$attachments[$i]["title"].'" rel="prettyPhoto[gallery]"><img src="'.$attachments[$i]["location"].'" width="128" height="120" alt="'.get_the_title().'" /></a>,
I want to slide down the pictures_entry_name_'.$i of this picture.
View 5 Replies
View Related
Feb 15, 2011
I have a form with a shipping address area and a billing address area. Right now I have a checkbox that fills in the billing address information if its the same as shipping information. Instead of having that so the form isnt so long when people first look at it I would like for the billing address fields to be hidden when you first come onto the page, and only if the address's are different the person will click the check box and the billing address section will appear. I know this has to be done in javascript but I have never done it
View 14 Replies
View Related
Jan 10, 2011
I have the following code that generates two dropdown boxes in a form, but I would like for the second to be hidden unless the first has 'Software problem' selected. Is it possible to do this?
<p id="parent-menu">
<select name='helpdesk-category' id='helpdesk-category' class='dropdown' tabindex="40">
<option value='-1'>Select a Category</option>
<option class="level-0" value="13">Software problem</option>
<option class="level-0" value="14">Hardware problem</option>
<option class="level-0" value="15">Suggestion</option>
<option class="level-0" value="16">General query</option>
</select>
</p>
<p id="toggle-menu">
<select name='software-category' id='software-category' class='dropdown' tabindex="50">
<option value='-1'>Select a Program</option>
<option class="level-0" value="6">BigHand</option>
<option class="level-0" value="7">IRIS</option>
<option class="level-0" value="8">MS Outlook</option>
<option class="level-0" value="9">MS Word</option>
<option class="level-0" value="10">MS Excel</option>
<option class="level-0" value="11">Oyez</option>
<option class="level-0" value="12">Internet Explorer</option>
</select>
</p>
View 2 Replies
View Related
Jul 9, 2009
I can't figure out why it dosen't work. I'd like to show/hide a <p> block depending on the value selected in the dropdown list:
$(document).ready(function(){
$('#report_rep_type').change(function(){
$('#report_rep_type').change(function(){
if($(this).text()!= 'Contigency Liabilities/Others')
$('#someElement').hide();
else
$('#someElement').show();
});
});
});
HTML code:
<form action="my action>
<fieldset>
<legend>Report details</legend>
<p>
<label for="report_rep_type">Report type</label><br />
<select id="report_rep_type" name="report[rep_type]"><option value="">Please select</option>
<option value="Scientific & Technical">Scientific & Technical</option>
<option value="Financial">Financial</option> .....
<p>
<button class="button " type="submit"><img alt="Tick" src="/images/silk/icons/tick.png?1245400388" /> Create</button>
</p>
</form>
View 7 Replies
View Related
Nov 26, 2009
I'm pretty bad with Javascript, but I need to hide or show a snippet of text (could be inside a div without problems) based on the selection of a dropdown menu (<select>). If they choose anything with the word "Series" on it, I need to show the snippet. If they choose anything without "Series" on it, then the snippet needs to disappear. I should mention the snippet is part of a form, just a checkbox but that shouldn't be a problem I don't think.
View 24 Replies
View Related
Jul 29, 2009
For example I have this sort code:
for ($i=0;$i<$db;$i++) {
$t1="toggleh$i";
echo "<div class='c'>Test<input name='$t1' type='image' id='$t1' src='test.png'/></div> <br>";
}
I try to make clear the screen for users, so I use hide & show to hide some row on screen what users actually don't need...
The JS part of code is something like this:
$('#toggleh0').click( function() {
$('div.showhide').toggle(400);
});
$('#toggleh1').click( function() {
$('div.showhide').toggle(400);
});
$('#toggleh3').click( function() {
$('div.showhide').toggle(400);
});
.
.
.
I dont know how can do this dynamic. So if "$i=6;" then I need toggle 0-6 function...
View 12 Replies
View Related
Mar 4, 2010
I'm trying to get the two followup questions underneath the checkbox to show up only if someone places a check there, but for some reason the way I've got it set up now it's simply hiding the area I want to show up altogether, and the checkbox has no effect on it.
Rather than waste tons of space pasting it here, here's the pastebin: [url]
Alternatively here is the live version:[url]
I'd prefer to have the form collapse when the additional questions are hidden, though if i can get this working at all.
View 2 Replies
View Related
Nov 19, 2010
I'm populating a couple of dropdown boxes from an xml file, but can't get them working independently. As you can seehtmwhen you select an item from the first select box (a polyline), itdisplays the corresponding item from the other box (a polygon), too.I found this answer on the google maps forum:"Don't know of an example, but building two select boxes isn'tdifficult: pass into your createMarker() function the relevant flag,and add the data to one of two variables (instead of everything beingadded to select_html as now).You shouldn't need two handleSelected() functions -- both select listscan use the same function because each select box passes itself("this") into the function."which is what I thought I did (making sel_html and select_html) butmaybe the two variables being discussed here are different ones?cross-posted on the google maps forum here and here but not answered.
View 1 Replies
View Related
Oct 18, 2009
For some security reasons I would like to show an email field in a form ONLY if the 4 checkbox are checked.I don't want to use server side coding so I need to use javascript.I have this code, showing an alert if the 4 checkboxes are checked:
<html>
<head><script>
var conta=0;
function ctr(quale)
[code]...
It works but I nedd to ask for an email instead of showing an alert.
View 3 Replies
View Related
May 29, 2005
How to show and hide form fields depending on a selected radio button.
View 14 Replies
View Related
Jan 21, 2010
I've got two dropdown boxes ('language' and 'word'). When the submit button is pressed, I want a div to show with the right word in it. I can do this fine with one dropdown box, but two has got me stumped.
View 6 Replies
View Related
Jun 22, 2010
Let me start by saying I'm a noob to JavaScript. What I'm trying to do for my website is have a select menu that shows the number of div's that's selected. I found a JS that I could do that with, but it only toggles, not change specifically what's selected. So if you click the wrong one, it doesn't work right.
[Code]...
View 2 Replies
View Related
Dec 31, 2010
I've created a gallery with multiple slideshows; each of them show/hide when you click on their corresponding link. The first slideshow appears when the page loads, but the others are hidden with a div style. It works great in most browsers, except Internet Explorer :(. For some reason, IE only shows part of the slideshows; the whole iframe is there, but only a small portion of the photos appear (although the slideshow itself also continue to run fine).
I realized that the problem is the div style (style="display:none; ). When I remove it from all the slideshows, then they appear fully instead of partially in Internet Explorer. However, the purpose of hiding them is defeated, as they all show up at once when the page loads. I want to keep them all hidden until you click on their respective link to show them. The page can be viewed here: [URL] Firefox shows how it should display....
[Code]...
View 2 Replies
View Related
Aug 11, 2010
I have a large form. One part of it is a column with selects. All drop-downs initially set to "No". The only other option is "yes". I need to make sure that at least one select is set to "yes". Any number, even all of them can be changed to "yes", but only one is required. I can easily add a rule that requires all the fields of the certain class to have certain type of value, but can't think of a way in js to only have one required. I can easily count number of "yes" values with PHP and prevent submitting on the back end, but would really like to have jquery do it first.
View 1 Replies
View Related