Clear Form Elements - Multi Selection Does Not Work
Dec 8, 2009
Do you know why js does not reset this multi select box?
<select name="LOB" multiple="multiple" size="5" style="background:#fff3b3;width:150px" >
<option value="DP"
>DP</option>
<option value="DTV"
>DTV</option>
<option value="HSD"
>HSD</option>
<option value="PPV"
>PPV</option>
<option value="RF"
>RF</option>
<option value="VOD"
>VOD</option>
</select>
Code:
function clearForm(oForm) {
var elements = oForm.elements;
oForm.reset();
for(i=0; i<elements.length; i++) {
field_type = elements[i].type.toLowerCase();
switch(field_type) {
case "text":
case "password":
case "textarea":
case "hidden":
elements[i].value = "";
break;
case "radio":
case "checkbox":
if (elements[i].checked) {
elements[i].checked = false;
}
break;
case "select-one":
case "select-multi":
//alert(elements[i].value);
elements[i].selectedIndex = -1;
break;
default:
break;
}}}
View 4 Replies
ADVERTISEMENT
Sep 29, 2010
I am just beginning to try to learn some js, and am making a site which requires a multi selection form with each being added up to reach a total. This sounds like a standard form, but this is a little different. I have files in megabyte sizes, from which people would choose what they wanted, and the total deciding how many dvds would be needed to store that many files...and this total could then be added to a js shopping cart. By the way, there is nothing illegal or pirated with the files in case you have any concerns.
View 1 Replies
View Related
Aug 25, 2010
I have a form that is pretty large, so to break it up I hide certain fields unless the information is required.
The problem is this. Lets say that I select that I a have a dog, put in some information in the newly shown fields, and then decide I don't want to say that I have a dog. If I select no to the dog question (the radio button that shows or hides the fields) the information I entered is still there. I need the information in those fields to be cleared when the fields are hidden.
this is the structure of my current HTMl [code]...
If the person says the have a dog, then all fields with class .dog_hidden will be shown, otherwise they are hidden. How can I select all form field types contained within a div of class="dog_hidden" and clear there value (either reset or set to an empty string " ") .
The goal is that every time the fields are hidden they need to be cleared or zeroed. Its important that this information never get put into the database (all fields with a value will be entered).
View 3 Replies
View Related
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
Sep 20, 2011
I have a tight space requirement here the explaination then code sample. I have a row of inputs and a link with a select set in the between in a div. I need to allow multi selection on the select which is the problem. The select must be within the div and when in non-select state set to 1 when the user is to make a selection I expand the select to 10. This causes the div to expand and any thing under to move in kind. I need a way to allow the select to expnad with out moving expanding the parent div.
<script >
function expand(){
mySelect.size=5;
[code]....
View 5 Replies
View Related
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
Feb 22, 2007
I have a multiselet box in which i identify the selected items. Once the user has finished selecting the items it causes the form to be submitted. For this example it just shows the selected indexes. To see the problem. Copy paste the code and save as html file. Then click on an item in the select box.
I am having problem with indentifying the selected items. When only one element is selected, the selected option index does not come up fine. I have no clue as to why this is the case. Code:
View 2 Replies
View Related
May 9, 2005
According to Google I'm the first person ever to have had this problem. I'm looking for the Gecko equivalent of document.selection.clear() or (better) document.selection.empty().
I'll try to lay out what I'm trying to do. I register an mouseup handler on the document to fire a function to find what text is selected. Code:
View 7 Replies
View Related
Sep 18, 2009
I am trying to get/set only text of list only element text value. But for some reason I can not select it in clear way. List something like:
<ul>
<li id="myid"> Here text that I want to modify
<ul>
<li id="dfdf">i don't want modify this</li>
<li id="dfdf">i don't want modify this</li>
[Code]...
View 1 Replies
View Related
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
Dec 10, 2011
I have a search form and added the "Clear All" Button functionality...but it clears the last part of the search form display preferences....how do I only clear the checkboxes at the top of the form only and not at the bottom of the form between the <DIV> tags? I have attached a copy of the JSP page.
View 1 Replies
View Related
Oct 20, 2011
I wanted to know if document.getElementById works while accessing form elements. I tried doing this just for testing purposes
This code doesnt work
function validateForm()
{
var val = document.getElementById("id_login").getAttribute("value");
alert(val);
return false;
[Code]...
Why doesnt document.getElementByid work with form objects.it works with all non form HTML objects..
View 1 Replies
View Related
Mar 14, 2010
I have a page I am working and I am having some trouble with: I need to show and hide areas based on a radio selection. I initally started using the show / hide feature in Jquery but the problem is the elements need to be removed but then put back if the user selects the radio buttonagain as it has form elements that have validaion on them. The validation is still trying to validate the form elements becuase they are still on the page but just not showing. This is the radio group the user makes the selection from:
<input name="terms_usr" type="radio" id="terms_usr_1" value="1"/>
<label for="terms_usr_1">Credit Card</label>
<input type="radio" name="terms_usr" id="terms_usr_2" value="2"/>
<label for="terms_usr_2">C.O.D</label>
[Code]....
View 3 Replies
View Related
Mar 10, 2010
Im using a JavaScript function to dynamically add rows of user-input data to a form, but Im having problems getting it to work properly with Firefox (works well in IE, though). We are using Struts 1.3 and JSPs, if that makes a difference.
The JavaScript function seems to work initially because the newly added row will show up on the JSP after the user enters their data and clicks a button that uses an onclick event to call the function. However, when I submit the form the new elements dont get included in the request. The result is that when I use the following code in my Struts Action Class to get all the parameter names submitted in the request, I dont receive the new form elements that were added by the JavaScript function and I cant process those newly added records:
Enumeration e = request.getParameterNames();
Here is the JavaScript code for the function that I call to dynamically add rows of data to the form.
function addData(tableId, distBedsCode, empCode, fte) {
var tbl = document.getElementById(tableId);
//grab how many rows are in the table
var lastRow = tbl.rows.length;
[Code].....
Ive tried using hiddenElem.setAttribute(name,) at the end of the above code, instead of something like hiddenElem.name = , but that didnt work. There is just some difference between the way Firefox handles things and the way IE handles them
View 3 Replies
View Related
May 22, 2009
I have a multi select in a form and underneath this corresponding check boxes which are initally hidden.
What I wish to do is when the user selects or deselects an item in the multi select the corresponding check box is toggled to either show or hide.
I was imagining it would be something like this, I'm not sure what to put in place of the question marks. I've already tried click and select
$(document).ready(function() {
//Hide the checkboxes
$('#checkBox1').hide();
//When the user selects an option toggle the visibility of the checkbox
[Code].....
View 2 Replies
View Related
Jul 23, 2005
how can clear an html SELECT and next insert in it all the elements of an array () I try this but seems doesn't works.
function ComboAddArrayValueWithLabel(combo,ArrayLabel,Array Value)
{
combo.options.length = 0;
for (i=0; i<ArrayLabel.length; i++)
combo.options[combo.options.length] = new Option(ArrayLabel[i],ArrayValue[i]);
}
View 1 Replies
View Related
May 23, 2010
I would like to have a main form (written in PHP) that has a "lookup" button next to a text field. When the user clicks "lookup", it should open a new window that lets them search (child.page1). When they enter a name or DOB into the search form, it submits the form through PHP (via POST), to a results page (child.page2). This displays all persons in the database which have a name or DOB == to the search term(s), with a checkbox next to each match. They click the checkbox (or alternenatively, a link), and return the checkbox value to the main window.
I have everything working right now, except that (child.page2) doesn't recognize the main window. If the data is entered on (child.page1), it works fine. I'm not very familiar with javascript.. is this even possible? I've considered using frames, to keep the parent-child relationship evident to the computer, but figured I'd check to see if there's an easier way.
View 4 Replies
View Related
Dec 8, 2010
I am trying to pre-populate form selections by evaluating a string. I will import a dynamic string later, but wanted to focus on the search function. If the value has a match in the string then write "selected" in the input tag to select it for the viewer. What am I doing wrong?
HTML Code:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>[code]......
View 2 Replies
View Related
Apr 18, 2007
I need a JavaScript that will allow me to clear a field in a form when I
click an image next to it.
View 5 Replies
View Related
Oct 23, 2002
I was wondering if its possible to clear a form after the form has been submitted. Like if a user hits the back button, I'd like the form to be blank. Is this possible?
View 1 Replies
View Related
Oct 5, 2010
I have this form which opens a new page after submitting the info. I would like to be able to clear the form after it's submitted.
HTML Code:
<form name="login" method="post" action="https://www.domain.com/register" target="_blank">
<input type="hidden" name="iso" value="gb" />
<input type="text" name="username" value="" />
[Code]....
View 8 Replies
View Related
May 28, 2009
I'm pretty new to Javascript and I'm trying to build a form which gives a configuration for a product. It consists of 5 drop down menus and each value in the drop down needs to have an image, a price, and a rule attached to it. The image sits above the drop down and changes with the selection, the price adds to the option prices selected in the other drop downs and give a total, and the rule affects what options are available in subsequent drop downs. I've got all of these working separately but can't get a single value to have all 3 functions.
View 4 Replies
View Related
Oct 29, 2011
PHP Code:
<html>
<head>
<script type="text/javascript">
function defaultDisplay(){
[Code].....
I have three images and I want to display one based on selection from dropdown menu. I have wriggten above code, but it does not work. Why is that ?
View 2 Replies
View Related
Oct 18, 2010
The javascript below works perfectly using Firefox, but not Opera or IE.I have a button which I would like to clear the text in the input field with.The "onFocus" on the input field works fine in all browsers, but when clicking the "cross.gif"-button, it only works in Firefox.javascript:
Code:
function checkclear(what){
what.value=''
[code]....
View 5 Replies
View Related
Feb 20, 2010
how to clear all input fields after submitting data?
[Code].....
i always find everyday on how can i clear the input fields after submitting on it.
View 9 Replies
View Related
Mar 11, 2005
I would like to be able to pass a multi-dimensional Javascript array through a form to a server-side script I am running. Any suggestions as to how to do this? I know how to asign a Javascript variable to a hidden field (basic stuff ), and if it was a single-dimension array I would join() it, but I don't know how to treat a multi-dimensional array. Any suggestions?
View 1 Replies
View Related