Hide Fields Depending On Selection

Sep 1, 2009

In the following code I am attempting to get certain fields to only appear if the user Selects dependent else those fields should be hidden.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"[URL]">
<html xmlns="[URL" xml:lang="en" lang="en">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<title>Display and Hide</title>
<script language="JavaScript">
function showhidefield(){
if (document.HelpAdd.RecordType.value == "Parent"){
document.getElementById("hideablearea").style.visibility = "hidden";
} else {
document.getElementById("hideablearea").style.visibility = "visible";
} }
</script>

</head>
<body>
<form name='HelpAdd' action='nextpage.asp'>
<table align="center" border="3" cellspacing="0" cellpadding="3">
<tr><td>Record Type:</td>
<td><select id="RecordType" name="RecordType" onchange=showhidefield()>
<option value='0'>Parent</option>
<option value='1'>Dependant</option><br/>
<tr><td>Topic Title:</td>
<td><input type="text" name="TopicName" ID="TopicName" maxlength="25"></td></tr>

<div id='hideablearea' style='visibility:hidden;'>
<tr><td>Parent:</td>
<td><select name="Parent">
<input type="text" name="ParentID" ID="ParentID" maxlength="25"></td></tr>
<tr><td>Topic Body:</td>
<input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $MaxFileSize ?>" />
<td><input id="helpfile" name="helpfile" type="file" /></td></tr>
</div>
<tr><td colspan="2" align="center">
<input type="submit" name="submit" value="Submit">
<a href="/help.php"><button>Back</a>
</td></tr>
<tr><td colspan="2" align="center">
<?php echo $Message ?>
</td></tr>
</table>
</form>
</body>
</html>

View 4 Replies


ADVERTISEMENT

Show / Hide Form Fields Depending On Radio Button Selection

May 29, 2005

How to show and hide form fields depending on a selected radio button.

View 14 Replies View Related

Hide/unhide Fields Depending Upon Other Fields?

Apr 26, 2009

i have to hide/unhide some fields on basis of some other fields. i found this script on the web.i can't understand the function completely what is the if ( txt.match(id1) ) block doing ?? is there any other way of doing the same...

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />

[Code]...

View 9 Replies View Related

Display Specific Input Fields Depending On Combobox Selection?

Nov 5, 2009

Within a classic asp webform (using vbscript) I would like part of the form (input boxes within table structure) to be specific/displayed depending on the users selection from the combo box in the row above.

I think the best solution would be using Javascript can anyone suggest a solution or example code?

View 1 Replies View Related

JQuery :: Making Dropdown Show / Hide Depending On Selection

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

Show / Hide Depending On Form Selection - How Best To Arrange Data

May 13, 2009

I have a big form which I'm tidying up by only showing elements when they become relevant, based on the currently selected input (eg to only show an option for 'waist size' when garment type 'jeans' has been selected). I've done this many times, and probably used a different approach each time, so I just wanted to see what other people do. It's currently along these lines: "If a particular option is selected, then show this element, otherwise hide it".

Code:
//the onclick handler
function checkViewType() {
//go through radio inputs in the cell and check what's clicked
document.getElementById('supplierOptions').style.display=radioCollection.supp.checked?"":"none";
document.getElementById('subCatOptions').style.display=radioCollection.subcat.checked?"":"none";
document.getElementById('subCatTimeOptions').style.display=radioCollection.subcat_sumtype_time.checked?"":"none";
document.getElementById('subCatSumOptions').style.display=radioCollection.subcat_sumtype_sum.checked?"":"none";
document.getElementById('subcat_weekmonth_span').innerHTML=radioCollection.subcat_time_week.checked?"week":"month";
}

But it's a big form, with lots of nested options, and some elements can be triggered visible by several different options. So I'm looking for an elegant way to handle this without a million if..elses. Perhaps an array of element ids and which elements are allowed visible when that's selected.

View 4 Replies View Related

Extracting Fields From A Db Depending On The Number Of Fields?

Jan 7, 2011

I have used this piece of code which is working great. It allows me to add different items from combo boxes to my order form. The problem is that i dont know how to extract the data from my db to display in a form view when i want to amend the i.e the number of items. Each record has a different number of items in it but are all lnked to one id. Is this possible to do. Any help on this would go along way.

stdhead("Home");
?>
<script type="text/javascript">
var counter = 0;
function add_phone() {

[Code]...

View 9 Replies View Related

Change Second Menu Depending On Selection In First

Feb 15, 2009

Basically I have a form, with two simple select menus, both identical except for different name values to post:

HTML Code:
<p>Make current?</p>
<select name="is_current">
<option value="yes">Yes</option>
<option value="no">No</option>
</select>
<br />

<p>Put in list?</p>
<select name="in_list">
<option value="yes">Yes</option>
<option value="no">No</option>
</select>

Some PHP code governs whether the "yes" or the "no" option in either menu gets the 'default' "selected="selected" showing, based on database information. For instance, in the first menu, if the page deals with a case where the the first "is_current" value is indeed current, then the PHP code will write the default "selected="selected" for "yes":

HTML Code:
<select name="is_current">
<option value=yes" selected="selected">Yes</option>
<option value=no">No</option>
</select>

If the page deals with a case where the value isn't current, the selected="selected" code will be written for the "no" value instead. The same goes for the second select menu. Now, the logic of my situation requires that, if the user selects "Yes" in the first "is_current" drop-down, then only "Yes" should be available to select in the second "in_list" menu. Anyway, I don't know javascript very well, but I found a function that seemed to be able to do this.

Code:
<script type="text/javascript">
(function () {
function updateLevel() {
var limit = Number(this.value);
// find the next select element
var selects = this.form.getElementsByTagName('select');
var select;
for (var i = 0; i < selects.length; i++) {
if (selects[i] === this && selects[i+1]) {
select = selects[i+1];
break; .....

(Apparently the script has to be put or called just before the </body> tag at the end of the page.) Then the select menus are recast as:

HTML Code:
<p>Make current?</p>
<select name="is_current" id="in_list">
<option value="1">Yes</option>
<option value="2">No</option>
</select>
<br />

<p>Put in list?</p>
<select name="in_list">
<option value="1">Yes</option>
<option value="2">No</option>
</select>

Now this appears to work, up to a point. If the user selects "Yes" for the first "is_current" selection, then only "Yes" becomes available for selection in the second "in_list" menu. A posted value of "1" represents "yes", and a value of "2" represents "no". Except, in Firefox, the javascript somehow overrules the default selected="selected" code. That is, the source code in the browser is correct, but the javascript draws it incorrectly.

For instance, say the database/PHP has drawn selected="selected" for the value "yes" in the second menu. Even though I can see that the source code is OK in the browser, the javascript will make the browser show a "No" selection as the initial default. This happens in Firefox, though not in Safari, and I haven't tested other browsers yet. This may be obvious but I'm not sure of javascript.

View 11 Replies View Related

DropDown List Popup Depending On Selection?

Oct 27, 2010

Here is my dropdown menu:
<select name="peeps">
<option value="Frank Tompson">Frank Tompson</option>
<option value="Henry Wilson">Henry Wilson</option>
<option value="Bill Kent">Bill Kent</option>
<option value="Jessi McDonald"> Jessi McDonald</option>
<option value="John Hays">John Hays</option>
How can I make it so if I click on John Hays a JavaScript pop up will say Hello John Hays, and if I click on Bill Kent a popup will say hello Bill Kent and if I click on any other name nothing happens?

View 3 Replies View Related

Changing Visibility Depending On Dropdown Box Selection

Aug 18, 2002

I want a text box which is only visible if the preceding drop down box has a certain option selected. Does anyone know how to do this or where I might be able to find the appropriate code?

View 7 Replies View Related

DropDown Change Background Image Depending On Selection

Sep 21, 2010

The code below lets a user select a drop down option and a picture changes depending on the selection. I am trying to make it so when you select an option on the dropdown the picture shows up in the center of the screen and in the background behind the text. Here is the code.

<html>
<head>
<style type='text/css'>
#txt {background-repeat:no-repeat;width:200px;height:200px;}
</style>
<script type='text/javascript'>
function div_bg(team){
document.getElementById('txt').style.backgroundImage="url(images/" + team + ".jpg)";
}

</script>
</head>
<body>
<select name='team' onChange='div_bg(this.value);'>
<option name='arsenal' value='arsenal'>Arsenal</option>
<option name='liverpool' value='liverpool'>Liverpool</option>
</select>
<div id='txt'></div>
</body>

View 19 Replies View Related

Change Background Picture Depending On A Drop Down Field Selection?

May 19, 2010

I need to achieve two things upon making a selection from a drop down field:

1) Changing the background picture of a cell.

2) Changing the size of a uploaded foreground picture within the same cell. code...

View 4 Replies View Related

Direct To Webpage Depending On Combobox Selection When Submit Button Clicked?

Sep 16, 2009

I've created a form with combobox with different values (this is for my website). What I want is when the user clicks 'submit' that it goes to a different page on the website depending on the value the person has selected in the combobox. Values are numerical, for example 1000, 2000, 5000 etc. I've been trying this for a couple of days now without success!

View 10 Replies View Related

JQuery :: Variable Validation Rules For Same Input Field Depending On Other Fields

May 30, 2009

I have the following html, field xxx requires a number from 0 to 100 when percentage is selected, and 0 to inifinity when dollar is selected.what's the best practice to setup validation for this?the key is to control the maximum value.I have tried depends expression in a max rule, but it doesn't seem that it can satisfy my requirement.

View 1 Replies View Related

JQuery :: Validate: Check Certain Form Fields Depending On Button Pressed?

Feb 4, 2011

I have a form with a series of fields. Only certain fields need to be validated when certain buttons are pressed. The reason for this is mainly because I had to build my own wizard style setup with jquery so, even though it's one big form, only certain bits need to be checked as they progress. I tried to tweak the accordion example given by the creators but it can't really apply to my scenario.

I've simplified the code down a bit and it is behaving exactly the same way as the big form...which is to say it's not behaving at all.

In this code, I want it to only validate field txt1 if button 1 is pressed and text2 if field 2 is pressed. One odd thing to note, when I set it up exactly as the site recommended with one big mass validation and such, it would only acknowledge the existence of the first field even though they both had class="required" on them.

<!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

Show Hide Table Row Depending On A Variable?

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

JQuery :: Show/hide DIV Elements Depending On Select Value?

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

Table Row Show/hide Depending On The Contents Of A Variable?

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

Jquery :: Realtime Order Form - Change Form Elements Depending On Selection

Aug 25, 2010

I've been struggling trying to get a small order form to work the way I want it to. Here is a link to the live page: [URL] And here is the code in question:

[Code]...

I have two questions...

Question 1 How can I make this piece of script act a little smarter. Look at the order form, I'm catering for up to 4 people and providing lunch for them. If they select 3 people and the spaghetti bol for lunch, it's only adding $10 where it should be adding $30. Obviously this is simple multiplication but since the values in my form are prices it makes it a little tricky. I'm guessing an onselect on the first part of the form which changes the pricing of the other items would be the way to go, but how do I do this?

Question 2 The "Total Price" is placed before the <form> tag by the script. This is ok but it's not where I want it. How can I position this text elsewhere in the document?

View 3 Replies View Related

Function To Hide Table Cells Depending On Whether Checkbox Is Checked Or Not

Sep 30, 2010

I am trying to write a Javascript function that checks whether certain checkboxes are checked or not, and then hides cells in a table if the corresponding checkbox is not checked, and makes cells visible if the corresponding checkbox is checked.

This is what I have so far:

Code:
<html>
<head>
<script language="JavaScript">

[Code]....

The above html gives a (3 rows x 2 columns) table where the checkbox in cell 1x1 (row1,column1) starts checked and corresponding cell 1x2 is visible - as required. However when checking or unchecking any of the checkboxes (which should run the javascript) the cell visibility is not changed.

View 5 Replies View Related

Listbox Selection To Autopopulate Fields?

Jul 23, 2005

I'm in the middle of adding some validation functionality to an inventory tracking form.

What I would like to do is have one dropdown menu/Listbox(Part Number) and another text field (Product Description).

When the user selects an item from the drop down (IE 12S0FB) it will autopopulate the text field with a description of the product. At the moment I will hard code the values in.

View 2 Replies View Related

DropBox Selection Opening More Fields

Nov 15, 2010

I need to create a drodbox menu in a way that when the thrid option is selected, it opens up a check box in the same form.

View 1 Replies View Related

JQuery :: Selection Field + Disabling Fields

Mar 18, 2011

The purpose of the jQuery code is that when you select an item from the select field that other items need to be disabled(works correct in all conditions) and that at the same time text in corresponding divs' text are altered. The thing is that the script basically works.. however when you've made a selection only the disabling works everytime but the divs are only updated once, so you need to refresh the page if you want to do it again..

[Code]...

View 1 Replies View Related

How To Show Hidden Fields Based On Selection

Oct 3, 2011

I want to know that "how to show hidden fields when a user selects a particular option in the html form"

I want the fields to be hidden first,then when the users selects:

Option A- Particulars fields which have I will create for this option must be displayed.

If

Option B-Particular field which I will create for this option must be displayed.

I want this code to run as soon as the user selects a option.Not on a button click

View 2 Replies View Related

How To Hide/show The Rows Of A Table Depending On The Value Selected By A User From A Drop Down List??

Feb 15, 2006

I am maintaining a site which is written in ASP. Now i have to create
some new pages.

In one page we have a table with many rows. Now, I want to enable or
disable(showing and hiding also) 2 rows of this table depending upon
the value selected by the user from a drop down list.

View 4 Replies View Related

Activate/Deactivate Fields Based On A Dropdown Selection?

Apr 29, 2010

On a registration form I have 4 fields that are all dropdown select fields. NAME, CLASS-1, CLASS-2, CODE

1) I would like to activate the CLASS-1, CLASS-2, CODE fields only if the NAME IS Selected from the dropdown.

2) Also would like to make the CLASS-1, CLASS-2 as required fields if the NAME is selected from the dropdown.

How can I achieve this? Can I use some kind of a server event to activate / deactivate the fields on the form?

View 12 Replies View Related







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