I have a webpage that uses visible and hidden tables to create the effect of going from screen to screen. Because a user might want to go back and change previous selections I have a "previous page" button that goes back to a table that has been made hidden. Text fields retain their values; but, option buttons do not. I am having problems restoring the original selections to the option buttons. I can post the code; but, the javascript functions are very long. If I have a pair of option buttons where the options are Yes and No I assign values to the variable names based on whether or not the "checked" option is true (eg: document.screenOne.nearWater[0].checked=true;). However when I go back to the "page" I cannot restore the original selection by reversing the process. For example, using the example above, if option "0" is "No" the following code does not produce the correct result. -
if(document.getElementById('nearWater').value=="No"){
-
document.screenOne.nearWater[0].checked=true;
-
} else if(document.getElementById('nearWater').value=="Yes"){
-
document.screenOne.nearWater[1].checked=true;
-
}
-
How can I restore the original selections to radio buttons?
3 1552
If the "page" (div/table) is simply hidden (probably by setting style.display), then it shouldn't affect any elements within the container element. Can you show the code for when you hide a container element, e.g. the function called when clicking Next.
This is the code for the first "page"
Here's the code for the first "continue" button and the swapnode function. -
<script type="text/javascript; version=1.5">
-
Node.prototype.swapNode = function (node) {
-
var nextSibling = this.nextSibling;
-
var parentNode = this.parentNode;
-
node.parentNode.replaceChild(this, node);
-
parentNode.insertBefore(node, nextSibling);
-
}
-
</script>
-
-
if(x=="clear1"){
-
document.getElementById('tableContainer1').swapNode document.getElementById('tableContainer0'));
-
document.getElementById('tableContainer1').style.visibility="hidden";
-
document.getElementById('tableContainer0').style.visibility="visible";
-
document.getElementById('tableContainer0').style.visibility="visible";
-
document.getElementById('insuredName').focus();
-
}
-
And, here's the code for the first previous page button -
function previousPage(x){// returns user to the previous page
-
if(x=='P1'){
-
document.getElementById('tableContainer1').swapNode(document.getElementById('tableContainer0'));
-
document.getElementById('tableContainer0').style.visibility="hidden";
-
document.getElementById('tableContainer1').style.visibility="visible";
-
if(document.getElementById('nearH2O').value=="NO"){
-
document.screenOne.nearH2O[0].checked=true;
-
} else if(document.getElementById('nearH2O').value!="NO"){
-
document.screenOne.nearH2O[1].checked=true;
-
}
-
setTimeout("document.getElementById('pState').focus()",100);
-
}
-
I know you didn't expect this much code; but the whole script section is 1658 lines.
I'm not sure why you're using swapNode here and why the radio buttons are reset, but the problem can be solved by getting the set of elements and then indexing them: - var nearH2Oval = document.getElementById('nearH2O').value;
-
var nearH2O = document.screenOne.nearH2O;
-
if (nearH2Oval == "NO") {
-
nearH2O[0].checked=true;
-
} ...
Sign in to post your reply or Sign up for a free account.
Similar topics
by: NotGiven |
last post by:
I'd like to have several levels of field selection. For example, field one
has three choices. Once you choose on form field one, several selections
show in field based that ARE BASED ON your...
|
by: Oscar Monteiro |
last post by:
I Have to sets of Radio buttons like so:
<input type="radio" name=p1 value=1>
<input type="radio" name=p1 value=2>
<input type="radio" name=p1 value=3>
<br>
<input type="radio" name=p2 value=1>...
|
by: Craig Keightley |
last post by:
I have a page that has n number of radio groups (yes/No)
how can i prevent the form being submitted if more than one radio group is
not selected?
By default all radio groups are unchecked
...
|
by: Alpha |
last post by:
Hi,
I'm working on a Windows applicaton with VS 2003 on windows 2000. I have a
listbox that I have binded to a dataset table, "source" which has 3 columns.
I would like to display 2 of those...
|
by: James P. |
last post by:
Help,
I need to display radio buttons on a form. The data is from SQL
table: each row in each table is displayed as a radio button. I have
multiple SQL tables so I understand I need to put...
|
by: kenny8787 |
last post by:
Hi, can anyone help here?
I have the following code generated from a database, I want to have javascript calculate the
costs of the selected items using radio buttons, subtotal the costs and...
|
by: brad |
last post by:
Group,
I'm using Visual Studio 2003 to create an ASP.NET 1.1 project which
contains nested server user controls in order to create a tree-like
hierarchy.
The tree is a sort of question and...
|
by: scanreg |
last post by:
My form needs to (1) direct to specified URLs based on a combination of form selections and (2) enable/disable form features based on selections within the form
FORM
Radio 1
- A
- B
- C
...
|
by: dpazza |
last post by:
Hi,
I'm creating a quiz on using a form in VB 2005 express.
I have four sets of questions and answers (labels and radio buttons)
and I change between which set of questions is currently shown on...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |