Manipulate The Value Of An Input Box Based On Whether A Checkbox?

Oct 6, 2010

I am trying to manipulate the value of an input box based on whether a checkbox is checked or not.
example checked input = 1600 and enabled unchecked input = 0 and disabled

I am having 2 problems: 1) When the page is loaded I get unchecked and input = 1600: it should be : either
checked input = 1600 and enabled unchecked input = 0 and disabled

2) When the checkbox is checked for the 2nd time the input remains 0 it should go back to the initial value 1600

[Code]...

View 2 Replies


ADVERTISEMENT

HTML- Manipulate - Check The First Checkbox In The Multibox?

Jun 1, 2011

I have a multibox in one of my JSP's that I want to manipulate via JavaScript, and have one of thecheckboxes selected.

The multibox property is "allChoices" in JavaScript, how do I check the first checkbox in the multibox?

The code I have now does not seem to be working:

View 1 Replies View Related

AJAX :: Populate The Third Input In The Same Row As The Second Input Based Upon A Separate Db Query?

Oct 29, 2010

I've got a form in which the fields are being dynamically generated based upon a db query.. it looks something like this:

Code:

<form name="bft">
<input name="colA_1"> <input name="colB_1" onBlur="loadXMLDoc(this.value,'colC_1');"><input name="colC_1">

[code]...

I'm trying to use AJaX to populate the third input in the same row as the second input based upon a separate db query. Here's the code for that:

Code:

<script type="text/javascript">
function loadXMLDoc(v,n) {
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari

[code]...

Here's where it displays on the page<cfoutput>#trim(getITRRSP.[columnName])#</cfoutput>
Whenever the focus blurs from those inputs, the third column in that row is populated with "UNKNOWN" as the value. I have confirmed that the getITRRSP.cfm file is properly retrieving and displaying the data from the db query.

View 1 Replies View Related

Set Variable Based On Checkbox Value?

Jun 12, 2011

Can anyone tell me how I can check to see if a checkbox has actually been checked or not? The code I need to use this in basically gets data from a form which has alot of dropdowns and a checkbox in it. The function builds a query based on the values it finds in these variables. I was trying to check to see if the checkbox was selected and if so assign a value to another var but I can't seem to get it to work.

The checkbox is called pics.
if (pics.checked) {
var photos = "Yes";
}
else {
var photos = "No";

[Code]...

View 7 Replies View Related

Changing A Checkbox Based On Another Box?

Jan 26, 2010

I figure this has to be simple, but I'm very green to javascript adn the examples I've found don't appear to work On an html form I have 2 checkboxes (A and B). Both are checked by default.

If the user clears box A, I want to clear box B. I don't want to hit a button, just change the box as soon as the user clears box A. I've attached an onclick= on box A, and created a simple script, but I don't even appear to getting into the script. Can someone provide or recommend an example that actually works that'll do this?

View 9 Replies View Related

Show - Hide Div Based On Checkbox ?

Aug 21, 2011

I know from scouring the Web that this is a very common Javascript question, but I have a twist on the question which is giving me headaches, and I hope some of the brilliant minds here at DaniWeb can help show me the error of my ways.

Say a user has checked a checkbox when submitting a form. I have a PHP script that records that check in a MySQL record. Later when they visit the page, the PHP script shows the checkbox as being checked. That's all working fine.

Now here's what I'm TRYING to do: Since the checkbox is checked when the page loads, I want a certain div to show up. And when the user UNchecks the checkbox, I want the div to go away. Simple, right?

Here's the Javascript I've placed in the header:

In the CSS, I've styled a div thusly:

And here's what I'm doing in the <body>:

This should show up when you click Yellow Box. And it should go away when you click it again. </div>

When I uncheck the checkbox (first click), nothing happens: the div still shows up.

Then when I re-check the checkbox (second click), the div goes away.

And then when I un-check the checkbox again (third click), the div comes back.

In other words, it's doing the OPPOSITE of what I want.

It seems that when I click the checkbox the first time (to uncheck it), the Javascript pulls an empty value. Only with the second click is it finding a value ('none').

View 3 Replies View Related

Change Variable Based On Checkbox?

Feb 22, 2011

i would like to declare a variable or input value called "module2" and have its value set at either M1 or M2 based on if a checkbox (called module_2 is selected or not. ie if the box is ticked module2 value="M2" .

i currently have something along the lines of this

function setmodule2() {
if(module_2.checked == true) {module2.value == "M2";}
else{idf_form.module2.value == "M1"}
}

[Code]...

View 3 Replies View Related

JQuery :: Selected Elements Based On Checkbox

May 2, 2011

I have the following HTML. I wish to select all the second column elements for only rows where the input is checked. For instance, if row 1 and row 3 was checked, I would want to select the td elements which contain row1_column2 and row3_column2.

<table><thead><tr>
<th><input type="checkbox" value="" class="checkAll" /></th>
<th>Col1</th>
<th>Col2</th>
<th>Col3</th>
</tr></thead><tr>
<td><input type="checkbox" name="cb[]" value="1" /></td>
<td>row1_column2</td>
<td>row1_column3</td>
</tr><tr>
<td><input type="checkbox" name="cb[]" value="2" /></td>
<td>row2_column2</td>
<td>row2_column3</td>
</tr><tr>
<td><input type="checkbox" name="cb[]" value="3" /></td>
<td>row3_column2</td>
<td>row3_column3</td>
</tr></table>

View 3 Replies View Related

JQuery :: Show Div Based On Checkbox's Checked?

Oct 4, 2010

I have a list of about 20 check boxes and I want a div to show when 3 have been selected as "Yes" option, how do i go about doing this?

Here is my html code:

<form>
<ul id="quiz-list">
<li>1. My bed partner complains that I snore.
<input id="select1" name="snore" type="radio" value="Yes" class="static_class style1" />Yes

[Code].....

View 5 Replies View Related

Hiding DIVs Based On Checkbox Selection?

Jun 11, 2010

I'm wanting to hide certain divs within a container. If the sub div DOESN'T have a checkbox which is selected in it, then it should be hidden when you click the link. eg: if #2 and #5 checbox only where selected then divs(sub_1,sub_3,sub_4) would be hidden when link was clicked.

[Code]...

View 11 Replies View Related

Change Font Color Based On Checkbox?

Feb 10, 2010

I have a form with 3 checkboxes. When user checks one of the boxes, additional fields show beneath the checkbox and the other 2 checkboxes are grayed out (locked). What I want is that when a user checks a checkbox, not only does the other 2 lock, but the text associated with them turn a different font color. I want it to appear as if the other checkboxes and text are being grayed out. BTW - I don't know any java, someone helped me with this and gave me this code so please try to be as specifica as possible.

For the lock function, I am using the following code:

<script language=JavaScript> var U=0;L=1; // (U)nlocked & (L)ocked
function doIt(_v)
{
if(eval("document.bgcheck.c"+_v+".checked"))
{
if(_v==2){lock(3);lock(4);}

[Code]...

View 3 Replies View Related

Disable All The Other Checkbox Based On The Selection Of First Check Box

Dec 11, 2007

disable all the other checkbox based on the selection of first check box

View 3 Replies View Related

Setting Cookie Based On Checkbox Selection By User?

Jul 23, 2005

I've got the following code snippet in a function to set a coockie based on whether or not the user selects a checkbox. Using an alert the cookie text looks fine but when I go to retrieve the values the only one it can find is the value for user. I've a few different things and none of them seem to work. I'm getting the same thing in both IE and Firefox. The only cookie listed is the 'user' with the proper expiration date. Code:

View 1 Replies View Related

Automatically Selecting A Checkbox Based On The Value Of A Radio Button

Mar 21, 2006

I want to automatically select a specific checkbox when a user clicks
(selects) a specific item in a radiobutton group. Both controls are in
the same form.

Let's say for argument's sake that the form looks like this
(inessential items left out for the sake of clarity):

<form name=form1>
<input type=radio name=Radio1 value=Option1>
<input type=radio name=Radio1 value=Option2>
<input type=checkbox name=Checkbox1>
</form>

I want to write some Javascript to automatically select the "Checkbox1"
checkbox when a user selects "Option1" in the radio button group.

View 3 Replies View Related

JQuery :: Dynamically Build A Table Based On A Checkbox?

Jul 16, 2009

I'm trying to dynamically build a table based on a checkbox being checked in the first td of every tr:

var tableID;
var isChecked;
var tableImportBuild;
function importData(id) {

[Code].....

I should note that isChecked points to a checkbox inside a table cell. I'm trying to clone the entire row the checked checkbox is in. If I alert $(tableImportBuild).html() from within the each loop I do get the result I was expecting but for some reason I don't have access to that variable once outside the loop.

View 1 Replies View Related

JQuery :: Updating A Form Based On Checkbox Selection?

Apr 12, 2010

I'm working on a search filter trying to get a form to update itself depending on what options have been checked from a selection of checkboxes. i.e. selecting one checkbox can bring up other checkboxes. It's just posting the form to update_filter.php and putting the updated form into searchNavigation div.

$(document).ready(function(e){
$("input[type='checkbox']").change(function(e){
e.preventDefault();
update_filter();

[Code]....

This works for the first checkbox that is checked, but after that nothing.

Is it something to do with the fact that the form is not the same form that it was before the checkbox was checked if that makes sense? or shouldn't that make any difference?

View 2 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

Change Button Text Based On CheckBox Checked Or Not

Apr 7, 2009

Currently on my page [PHP5] I have a checkbox & a input button (among other things), the button text now is hardcoded to "Next" but I need this to change based on the status of the Checkbox (cBusAcc). For example, when cBusAcc is not checked the button should be "Create", when it is checked the button should be "Next".

And this change should occur without the user needing to press on the button, just check/uncheck should change the button test...
See the code I have so far below...

...
<input type="checkbox" name="cBusAcc" id="cBusAcc" />
<input name="signup" id="signup" type="submit" value="Next" />

View 1 Replies View Related

Pre-check Checkbox Onload Based On Previous Message

Apr 22, 2010

I am creating a form in which a checkbox is checked based on the info from previous page.The info I am passing is the client ID (which is a number I can pass in the URL variable)In the form I have a list of clients (with checkboxes next to them)Now if you come from a specific client page the checkbox with the client name should be already checked since you are getting info regarding that client, with the option of selecting other clients.So any idea on how I can accomplish this using Javascript?

View 1 Replies View Related

JQuery :: Show / Hide Images Based On Checkbox State?

Apr 13, 2010

What you can see is that I have a bunch of images which form a chart, each of the images has multiple classes.I want to write a function which when called fades in/out images dependant on whether all related checkboxes are checked or not.Checkboxes are related to the images by id on the checkbox and class on the image, as I'm sure you can see. I will be calling this method each time a checkbox is checked.

View 2 Replies View Related

Show - Hide Form Fields Based On Checkbox State

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

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 View Related

JQuery :: Change Field Value With Ajax Call Based On Checkbox State?

Mar 31, 2010

I've created a registration form with sponsorship options hooked to checkboxes. My original form used ASP to keep values in hidden fields to use for totaling everything at checkout time.

Now I'd like to use PHP and Ajax to place the value into the text field related for each option checked.

I'm able to do that making an Ajax call. My problem that I need help with is this: If the visitor decides to uncheck a sponsorship option, the value placed in the associated field remains on the form. How do I replace that value with a null or empty string if they decide to uncheck their original choice?

I've tried JavaScript to no avail so far, both in the client side and server side code. I'm very new at this and I need help. Will jQuery work without having to change a bunch of code?

View 11 Replies View Related

JQuery :: Using Check/uncheck Multiple Checkboxes In A Specific Row Based On Another Checkbox?

Jul 29, 2011

someone here might know what I'm doing wrong. I have a list of checkboxes, in multiple rows with each along the lines of:

[Code]...

View 3 Replies View Related

Dynamic Type Of Field Changing Based On Checkbox OnClick Handler

May 1, 2006

I'd like to know if its possible to shift a select option field into a simple text field based on a check box filled by user.

I have an asp form that carries a few select options. One of them I'd like to permit free editing if the user selects a check box just biside the select option, so enableing free editing by user.

View 2 Replies View Related

Checkbox Input - How To Control Output

Apr 12, 2011

I am trying to make a bunch of checkbox inputs and then a button input. when you click the button it will display all the checkboxes clicked. If I can control the output that would be great (not "true", like I want to type my own alert), anyone know how? I just want the simplest way, no ifs or elses or anything like that.

View 6 Replies View Related







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