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.screen One.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 1566 acoder 16,027
Recognized Expert Moderator MVP
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.
acoder 16,027
Recognized Expert Moderator MVP
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 selection in field one. Field
three selections are based on field two,...
If you know of a good tutorial or site recommendations, I' appreciate you
posting them here. Thanks.
|
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>
<input type="radio" name=p2 value=2>
<input type="radio" name=p2 value=3>
then a text area and a button:
|
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
The problem i am facing is that i do not know how many yes/no radio groups
will be generated
|
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 columns, "scode" and "sname", as 1 column
(if not possible then 2 columns will be fine) in the listbox. Can the
listbox display 2 columns information from the dataset and how can I do that?
Also, I set the property of the listbox to selectionmode...
|
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 them each in a
GroupBox. All the examples I saw from the books or from the web show
me how to add static radio buttons at design, or dynamically at run
time but with fixed radio buttons (like from an array).
I need to create radio buttons based...
| |
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 grandtotal the costs
ready for the selected items to be inserted back to the database. I did something like this
before with Checkboxes, but Radio button have to be named the same to maintain their
groupings.
|
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 answer dialog. The user answers a
question, and the next subquestion appears (using dynamic html
display:none|block) depending on his answer.
|
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
Select Box 1
|
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 the
form by changing the visible state of the radio buttons and labels
utilising back and next buttons.
E.g. Next button makes current radio buttons and labels invisible and
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |