JQuery :: Toggle Visibility Of Textbox Based On Status Of Checkbox

Dec 8, 2010

This is using jquery by the way. I have a list of ethnicity on a form for a person to enter that are checkboxes. One option is 'Other, specify'. When 'other specify' is checked, I would like a text box to pop up and disable the other boxes (if you pick other, you can't pick from the previous ethnicities). If 'other, specify' is unchecked, I would like for the text box to disappear and re-enable the checkboxes. I had the appearing box working just using JS. I can't seem to get the syntax right to use the toggle feature of jquery to make the box disappear when unclicked.

JQUERY
<script type="text/javascript">
$(function(){
$('#other').click(function(){
$('#otherrace').toggle(
function(event) {
$(event.target).css('visible');
},
function(event) {
$(event.target).css('hidden');
});});
</script>

HTML
<input type="checkbox" name="race" value="asian" />Asian<br />
<input type="checkbox" name="race" value="hawaii" />Native Hawaiian or other Pacific Islander<br />
<input type="checkbox" name="race" value="noanswer" />Choose not to answer<br />
<input type="checkbox" name="race" id="other"value="other" />Other, specify<br />
<div style="visibility:hidden" id="race"><input type="text" name="fname" size="25" maxlength="25" id="otherrace" /></div>

View 3 Replies


ADVERTISEMENT

Change Checkbox Status Instead Of Inserting Value In Textbox?

Apr 19, 2009

How can I change a checkbox status instead of inserting a value in a text box? As it is now the script below just inserts a 1 or 0 in a textbox.

Code JavaScript:
if (document.form2.putt0.value===''){
document.form2.g0.value = "0"
} else {
if (gir0 <= pa0 - 2) {
document.form2.g0.value = "1"
} else {
document.form2.g0.value = "0"
}}

View 13 Replies View Related

Validate A Radio Group Based Upon The Status Of A Checkbox?

Sep 21, 2009

I am trying to come up with a script that will validate a radio group based upon the status of a checkbox.If box is checked radio button is required else it can stay false.here is as far as I have gotten so far. just a basic if statement but i need to incorporate the check box

Code:

function validate_form ( )
{
valid = true;[code]......

View 1 Replies View Related

Simple Method To Toggle Textbox Yes - No Using CheckBox

Dec 12, 2010

Looking for a simple method to Toggle textbox yes/no using CheckBox

This example does not work!

What I am trying to do:

View 2 Replies View Related

JQuery :: Noob : Toggle Visibility Of A Target Div From <a H?

May 3, 2009

I have just started trying to use jquery and though it looks cool and simple I'm having really problems working out how to do a really simple thingAll the examples I've seen use css selectors to target an element in the page but i need to use an id.basically I have a list of <a href> links and a load of <div>s that are all display:none by default when the page loads. The <a href> links and <div> elements are written dynamically by a php loop.What I would like to do is click on an <a href> link and make a specific <div> visible using its id. Sounds simple doesn't it ? But I can't figure out how to do this with jquery syntax.In traditional js syntax I would write a function that would receive the id of the target div as an argument when the <a> tag is clicked. Then I would loop through all the divs and make them all display:none and then display the target div.would i still need to put an onclick event in the <a href> links ? or is there a way of getting the id of the <a href> and using that to target the correct <div> ?

View 6 Replies View Related

JQuery :: Plugin To Toggle Password Visibility?

Aug 12, 2011

I got the functionality of this plugin working tonight. It allows for a checkbox or link to make the password field of a form show the hidden characters, because sometimes it's nice to see them. I turned it into a plugin, and because I still consider myself a beginner with javascript, I thought I'd ask for a review so hopefully I can learn something. I tested it in FF5, IE7, IE8, IE9, Latest Opera, Latest Chrome, and Latest Safari.

Code JavaScript:
(function($){
$.fn.passwordToggle = function(options) {
/* Set defaults */

[Code]...

View 11 Replies View Related

Jquery :: Toggle Visibility Of Many DIVs With Images Inside

Jan 9, 2010

I'm pretty new to JavaScript and I've been searching for a way to toggle the visibility of many divs with images inside. Basically I want to have nothing visible, then I have three links that represent three categories of the images. So for example if the user clicks the link "Illustration" I want all the divs with the class illustration to appear. But when the user chooses a new link say, "typography" I want to hide the divs with class illustration and then show the divs with class typography.

View 1 Replies View Related

JQuery :: 'if' Statement - Class 'linklast' - Removed - Toggle The Visibility

Jul 6, 2010

Look at my "Fiddle":[url]

I'm having problems with the jQuery 'if' statement. When the div 'accord3' is hidden, I'd like the class 'linklast' to be added to 'Schools' --> the bottom corners are rounded. When the div 'accord3' is visible, the bottom corners must be square, meaning the class 'linklast' has to be removed. This has to be able to switch back and forth while I toggle the visibility.

View 1 Replies View Related

JQuery :: Only 1 Div Toggle Status?

Aug 19, 2011

I'm currently working with fadeToggle and what I got here seems to do the job quite well! When a span element is clicked that's inside an li element it fadetoggles the next div that's inside the li element.

<script type="text/javascript">
$(document).ready(function () {
$('.show_hide_wrapper_config, .show_hide_wrapper_social_media').hide();

[code]....

I only want one div to be toggled and currently they don't close after a next span is clicked!you can see the website. If you click on the linkedin and the facebook icon next to the line "now compatible with" you'll see what I mean.So is there a way to close the div when a next span is clicked.

View 1 Replies View Related

JQuery :: Checkbox, Getting Status Of Checkbox?

Aug 11, 2010

I'm having some trouble with determining the status of a checkbox after it has been clicked with the jquery.checkbox plugin

[Code]...

View 2 Replies View Related

Toggle The Visibility Of One Div By Clicking On Another ?

Feb 16, 2011

I am creating a website as part of a university project. as part of this i am trying to make a menu in the top right. after looking around i have found javascript top be the best way to do this. how would i go about making it so that when i click on one div (called map) a separate div (called mapMenu) visibility is toggled.

View 3 Replies View Related

Toggle DIV Visibility After Link Followed

Oct 29, 2011

I've got a script that toggles the visibility of a div on "dashboard.html":
$(document).ready(function(){
$("#add_networks_wrapper, .remove_box").hide();
$(".toggle_add_networks").show();
$('.toggle_add_networks').click(function(){
$("#add_networks_wrapper, .remove_box").slideToggle();
});
});
On "dashboard.html" it works great. The div "add_networks_wrapper" is hidden until I click the link that toggles it. What I need is a link from a different html page (say "account.html" or whatever) to open "dashboard.html" with the hidden div's visible.

View 1 Replies View Related

Toggle Div Visibility After A Link Is Followed

Oct 29, 2011

I've got a script that toggles the visibility of a div on "dashboard.html":

On "dashboard.html" it works great. The div "add_networks_wrapper" is hidden until I click the link that toggles it.

What I need is a link from a different html page (say "account.html" or whatever) to open "dashboard.html" with the hidden div's visible.

View 7 Replies View Related

Toggle Not Just Visibility, But Existence?

Feb 19, 2009

I'd like to be able to toggle the existence of a DIV using the onclick attribute.

HTML Code:
<input type="radio" value="1" checked="checked"
onclick="document.getElementById('div').style.visibility='hidden';"> 1

[code]....

View 2 Replies View Related

Toggle Visibility After A Link Is Followed

Oct 29, 2011

I've got a script that toggles the visibility of a div on "dashboard.html":

Code:

On "dashboard.html" it works great. The div "add_networks_wrapper" is hidden until I click the link that toggles it.

What I need is a link from a different html page (say "account.html" or whatever) to open "dashboard.html" with the hidden div's visible.

View 2 Replies View Related

Toggle The Visibility Of Several Items At Once?

Jan 9, 2009

Was wondering how to accomplish this.I have several table rows that I would like to hide all with the push of a button.For instance:

Code:
<tr id="objects_row1"><table class="apples">
<tr id="apples_row1"><td>asdf</td></tr>

[code].....

View 4 Replies View Related

Toggle Visibility Of Element - OnClick Function

Sep 6, 2009

I found this little script and it works fine but the only thing is when the page first loads it displays the "This is foo" text. I would like it to not display the text until it is clicked. So instead of it displaying "This is foo" when the page loads I would like it to not display anything.

Here is the script:
Code:
<body>
<script type="text/javascript">
<!--
function toggle_visibility(id) {
var e = document.getElementById(id);
if(e.style.display == 'block')
e.style.display = 'none';
else
e.style.display = 'block';
}
//-->
</script>
<a href="#" onclick="toggle_visibility('foo');">Click here to toggle visibility of element #foo</a>
<div id="foo">This is foo</div>
</body>

View 9 Replies View Related

Toggle Visibility - Show / Hide Frame

Mar 2, 2007

I've a frameset in my application.
1. A header Frame. (header)
2. A Tree Frame (left)
3. A Main Frame for displaying main contents. (mainFrame)

Well, I just want to toggle the visibility of the Left Tree frmae to provide more space to the Contents page when required.
> There can be a button which will have the label as HIDE when frame is visible.
> And when frame is hidden, the buttons label should be SHOW, clicking on which should show the frame baxck in its place.

View 3 Replies View Related

Link To Toggle Visibility On A Separate Page?

Oct 29, 2011

I've got a script visibility of a div on "dashboard.html":

Code:
$(document).ready(function(){
$("#add_networks_wrapper, .remove_box").hide();

[code]....

View 1 Replies View Related

Toggle Visibility On Multiple Elements Simultaneously?

May 14, 2009

I am working on a project that shows archived data as well as current data on the same page. When the page builds, current data is shown, archived data is hidden (by using a div with id="archive"). I found comments here that getElementsByName was not a good cross browser way to handle this (and I'm not sure how to use that anyway). Can someone suggest the correct way to handle this?

There should be a link that, when clicked, will grab each element on the page with id="archive" and toggle the display property (none or block).

Here is the current code:

function archives(toggle) {
if (typeof(toggle) != "undefined") {
if (document.getElementById(toggle).style.display == 'none') {
document.getElementById(toggle).style.display = 'block';

[Code].....

This works just fine, but only for the first element that it finds. I need many elements with the same name to be effected.

View 3 Replies View Related

JQuery :: Get The Status Of A Checkbox?

Feb 16, 2010

I have a checkbox that will either be ticked or not:

HTML Code:
<input type="checkbox" id="chk_code_of_conduct">

I am trying to grab the current value of the checkbox every time it changes, and display it in an alert box. But regardless of whether or not the box is ticked, the value always gets displayed as "on":

HTML Code:
$(document).ready(function() {
$('#chk_code_of_conduct').change(function() {
alert('The value is ' + $('#chk_code_of_conduct').val());

[Code]....

View 3 Replies View Related

JQuery :: Clicking Checkbox Doesn't Change Its Checked/unchecked Status?

Apr 2, 2010

I have a set of checkboxes that trigger events on a page. Clicking a checkbox triggers the event correctly and the checked attribute changes in the page source, but in the rendered browser view the checkbox status remains changed. If I load the page with the checkboxes checked, they always remain checked in the browser view. If I load the page with checkboxes unchecked, they always remain unchecked in the browser view.

If I remove the jquery code the checkboxes work as expected, but obviously don't trigger any events. I've tested this in both Safari and Firefox with the same results.

[Code]...

On another note, I'm having problems with the back button when using the forum. If I am looking through a multi-page search and click on a topic and then click the back button, I go to the first page of the search instead of the last page I was looking at. Similarly, when I first previewed this post and clicked "back" I was returned to the topic list instead of the compose-post page.

View 2 Replies View Related

Textarea Visibility Based On Dropdown Selection?

Feb 1, 2009

I have a form which has a dropdown menu on it. The last option on the menu "other". When "other is clicked, I would like a textarea to become visible, so that the user can enter the new information. Does anyone know how I might do this?

Here is the html for the form:

HTML Code:
Union: <select name="union" id="union">
<option value="choose">Choose One</option>
<option value="ibew">International Brotherhood of Electrical Workers</option>
<option value="ibt">International Brotherhood of Teamsters</option>

[Code]....

View 6 Replies View Related

Set Checkbox Status - Works In IE But Not FF

May 16, 2007

At the top of a page I'm displaying a check box thus:

<input type='checkbox' name='ckbx1' onClick='saveStatus("ckbx1");'>ABC

I then execute the following to set the check box to whatever it was the last time it was changed:

<script type='text/javascript'>
document.getElementById('ckbx1').checked = getCookie('ckbx1');
</script>

This seems to work ok in IE6 but in Firefox a "...has no properties" error is generated when the script executes. The same error is generated when I click on the check box.

View 2 Replies View Related

Checkbox Visible But Status Undefined?

Aug 11, 2011

The following excerpt is part of a very huge project(in terms of code involved). Pardon me if it lacks a bit of context. But I assume I have posted adequate information for understanding the problem.

var sztitlebar_specific= "<table cellpadding='0px' cellspacing='0px' width='100%'><tr>" +"<td class='tiletitle'>"
"<img src='../images/alert.gif' onclick='toggleAlerts("#ID#")' alt='Toggle Alerts' title='Toggle Alerts' style='cursor: hand'>" +

[Code]....

But when I alert the status of the checkboxes they show up as "undefined". As you can see, the first piece of code defines a titlebar with a button and a couple of checkboxes and the name of the titlebar. And it is these checkboxes that remain undefined even though I can see them and check and uncheck them. But the name of the titlebar gets passed to the function correctly when the onclick event fires and it gets alerted.

View 1 Replies View Related

JQuery :: Multiple Checkbox Toggle Respective DIV

Mar 9, 2010

I have some jQuery code to add and remove a class to toggle an image. It works for one but now I want it to work if I add other checkboxes. Currently all the checkboxes change the 1st div. I would like to make it toggle it's respective div.

<html>
<head>
<title>jquery to Show/Hide a Div</title>
<script type="text/javascript" src="[URL]"></script>
<script type="text/javascript">
$(document).ready(function(){
$("input").removeAttr("checked");
$("input").click(function(){ .....

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved