Passing Variables To Functions - Disable Elements Of A Form Based On Which Options Are Selected

Feb 2, 2010

I'm trying to make a function that will disable elements of a form based on which options are selected.

I have made this work for individual form controls but now i want to make it into a function that could be used on any form control.

Here is the broken function

Code:

I've probably just missed something but i really cant see what?

View 9 Replies


ADVERTISEMENT

Disable Form Elements Based On Check Box Being Checked

May 12, 2011

I have an array of list boxes. I need them to become disabled if the first one is checked (with an id of disabler_0), and I need them to be enabled if that box is unchecked. Right now it doesn't work.

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js"></script>
<script>

[Code]....

View 1 Replies View Related

Disable Options In One Menu Based On Selection In Another

Feb 22, 2011

I am new to javascript stuff but am looking to develop a form which includes 2 drop down menus but I would like to grey out some options in the second one based on the selection in the first. Basically this is a simplification of what I have:

<select name="orientation" id="orientation">
<option value="OR1">South</option>
<option value="OR2">East</option>
<option value="OR3">North</option>
<option value="OR4">West</option>
</select>

<select name="location" id="location">
<option value="L1">Front Left</option>
<option value="L2">Front Right</option>
<option value="L3">Rear Left</option>
<option value="L4">Rear Right</option>
</select>

What I would like is that if south or east are selected for orientation then I can only select front left or front right but if north or west are selected then only rear left or rear right are available.

View 3 Replies View Related

Total Prices Based On Selected Options

Jun 20, 2005

I am trying to create a “simple” form with 3 dropdown options which totals up the value of the 3 selections. My script is based on one I have used in the past which used checkboxes… checkboxes work fine, but I can not get the script to work with dropdown options. I can get a string to build but totals are always 0. Code:

View 6 Replies View Related

Passing Variables In And Out Of Functions

Nov 3, 2010

To formulate the problem simple i have two buttons with the onclick function:

I guess what im asking is how can you set a variable by one onclick function and then use it in any other function?

View 1 Replies View Related

Passing Variables To Multiple Functions?

Sep 5, 2010

I'm new here, and new to js. Here is my problem: I have written out a code to make an image switch from state 0 to 1 and back to 0 again (an eye blink). The code works fine, but I would like to write the functions with arguments so it could be applied to more images. I have tried for a few hours (and searched forums) and am getting no where. Here's my code.

Code:
function home_blinkDown()
{
//alert('blink down');
var t = setTimeout("home_blinkSwap('home_js', 'images/main/home_blink.png')", 2000);

[Code]...

View 5 Replies View Related

Passing Values Of Variables Between Functions Not Working ?

Aug 12, 2010

I'm trying to trap a user entry that cannot be found in the database. When a code is entered, the page should give a "Code Not Found" message if it is an undefined value.

However, it didn't; and it always shows the "undefined" value to the page instead.

Here's what I actually did:

getting user input:

Finding the code:

View 1 Replies View Related

JQuery :: Passing Local Variables To Callback Functions?

Jun 2, 2011

for some time I always found a workaround for this kind of problem. But somwhow, it feels wrong. So I'd like to know, if there's a common way to solve something like this[code]...

I'm defining the function and if the value of 'obj' hasn't until the function really gets called, this can work. But it just feels so wrong do have always global variables just to access them inside of a callback.[code]...

View 4 Replies View Related

Disable The Text Box, Based On The Value Selected From The List Box?

Dec 30, 2010

I want to disable the text field base on the value selected from the list box.

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

SHow / Hide Elements Based On Selected Option

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

Form Effects: Number Of Options Based On Dropdown Selection?

Jul 22, 2009

I have been searching for hours and have not found what I am looking for. BUT, I have seen it before when I was NOT looking for it. haha!

Anyway, I am creating a form. And the form has an element that asks for "How Many Children?" followed by a dropdown from 1 to 6.

Well I would like to display another set of elements from 1 time to 6 times, based on their selection.

Name: ___ Age: ____ Sex:____

That will be displayed as many times as the user selects.

View 4 Replies View Related

Passing Variables To Form?

Jul 8, 2009

I have a javascript function that receives the form name, field name and value and I want to be able to spit that data back to the originating form after doing some processing on the data.

The values are making it to the function perfectly, but when I try to return those values to the form, it tells me it's not a function. I know there's some syntax problem, but I'm just not sure where!

function doThis(one,two,three){
var myFormName = one;
var myFormField = two;
var myFormValue = three;
var goHere = myFormName + '.' + myFormField;

[Code]...

View 4 Replies View Related

Passing Variables Into A Function From A Form

Jan 3, 2011

I have a vague idea of what might be going wrong but I have no idea what I should be doing instead. Here is what I'm trying to do: User inputs X and Y coordinates into form validate that they are numbers do a little bit of maths redirect to a php script with a single variable tacked onto the end of the url Here is the form code:

//part of a larger php script to make the form
echo "<form name='gotoForm' onsubmit='return coordCalc()'>
<fieldset>
<legend>Go to Square</legend>
X <input type='text' id='X' size='1' maxlength='3'/>
Y <input type='text' id='Y' size='1' maxlength='3'/>
<input type='submit'
[Code]...

View 7 Replies View Related

Does Form.disable Work On Hidden Text Form Elements?

Jul 23, 2005

Does "document.formName.elementName.disable" work on hidden form text
elements? I have a form with some input fields that are associated with
some hidden text fields and I would like to disable all of the
categories inside the form when the page loads and only enable each
category as it is needed. Code:

View 3 Replies View Related

Retreive Url Variables And Put Into Form Elements

Apr 29, 2005

I am trying to pull two variables from a url and insert them into the appropriate text fields in a html form.

URL:
orderform.php?shape=Longboard&model=Cutter

I have this javascript, which searches the url string, HOWEVER it pulls the string into one variable. ie - Shape: LongboardCutter - INSTEAD OF: Shape: Longboard - Model: Cutter.

<script language="JavaScript">
document.form1.shape.value = location.search.substring(1);
</script>
[b]How do I get the javascript to pull the two variables seperately?[]

View 3 Replies View Related

Enable/disable Form Element Based On <select> Choice?

May 30, 2011

Is there any way to enable a form element(s) based on the selection in a <select> drop-down? I'm trying to enable/disable a group of checkboxes depending on which option is chosen in the <select> above it.I know how to enable/disable something when a box is checked (or text is entered into it) but I have no clue how to handle the <select> option.

View 2 Replies View Related

JQuery :: Disable Form (sibling) Elements?

Oct 19, 2010

What is the selector to disable all form elements on the same 'level'? What I have is this:

Code:
<form>
<input id="element1" name = ........ />

[code]....

View 7 Replies View Related

GetElementById/form.elements - Get The Value Of A Selected Option Value?

Sep 16, 2010

I'm trying to get the value of a selected option value. I've tried using getElementById("fieldname").selectedIndex.value and formname.elements["fieldname"].options[selectedIndex].value with no joy.

View 1 Replies View Related

Show/hide Elements Of A Form Based On Drop Down Box Selection

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

Disable A List Box If A Previous One Is Not Selected And Enable If Selected?

Aug 6, 2009

I have various list boxes in a web form. I need list box No. 4 to be disabled until a selection is made in a previous list box, the No. 2 listbox. If some selection is done in listbox No. 2 then I can do a selection of list box No. 4. How can I do this?

View 2 Replies View Related

JQuery :: Show/hide Form Elements Based On Radio Button Selections ?

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

Replicating 'disable' For Menu Options In IE

Jun 8, 2007

I have a menu with a lot of items that open pop-up windows when clicked on. The first item on the menu is purely intended as descriptive and default selection on the menu and is given the 'disabled' parameter- which makes the option inactive(greyed out) in Firefox; but has no effect with IE which goes ahead to open a blank pop-up window.

Please who knows how I can make a menu option to be 'disabled' in IE.

View 2 Replies View Related

Changing Selected Value Of Options Tag

Jun 1, 2006

In JS, how can I change the selected value of a dropdownlist(select options)
I know the value of indexed value of the selected value before it is changed.

View 4 Replies View Related

Select Box Options To Disable/enable Checkbox?

Jan 18, 2006

I need to be able to uncheck and disable a checkbox based on the option selected in a Select list.

This is what I tried.

==============
<script type="text/javascript">
function GetOptVal(OptVal)
var OptVal;
{
if(OptVal="XX") document.form1.chkbox1.disabled = false;
}
else
{
document.form1.chkbox1.checked = false;
document.form1.chkbox1.disabled = true;
}
</script>
<form name="form1">
<select name="Opt1"
onchange=GetOptVal(document.form1.Opt1[document.form1.Opt1.selectedIndex].value)>
<option value=" ">Select One</option>
<option value="XX">XX</option>
<option value="YY">YY</option>
<option value="ZZ">ZZ</option>
</select>
<input type="checkbox" name="chkbox1" />
</form>

View 2 Replies View Related

JQuery :: Getting Array Of Selected Options?

May 17, 2011

I have a product page that allows each specific item of clothing to have any number of various options. For example the admin may allow that a specific jersey can have your last name on the back and your team number, or maybe your nickname on the sleeve. These options each have an additional price, the name on the back may be $3.00, the number $2.00 and the nickname $5.00. I currently have a function like below that adds the additional fee to the total when you fill in that text box:

$('input').blur(function() {
var option = $(this).attr('id');
var value = $(this).val();

[code]....

and on the shopping cart I want to display:

Custom Name: Williams
Custom Number: 17
Custom Nick Name: Booger

I can use PHP to convert customName to Custom Name by looking up that option in the options db table but how do I build the JavaScript Array before I pass it to $_POST? Each element should have the value and price and it's key should be the options name...

View 6 Replies View Related







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