[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1995
  • Last Modified:

web forms with multiple tabs

I'm having problems implementing web forms with multiple tabs. I want to store a range of input data from these multiple tabs into a database.

I use a DIV for each TAB and javascript functions to enable and disable the tabs.
1st problem: When the page is first loaded I call the showPanel(1) to make the first tab visible and others 'hidden'. Although I set other tabs as 'hidden', I still can go to other tabs before completing the form on the first tab. How do I make it totally disable?

2nd problem: I call showpanel(1) when the page is loaded. e.g. <body onLoad="showPanel(1)">. So, everytime I refine the listbox on other tabs (e.g. tab 2, 3) and the page is refreshed, it always go back to the first tab. How do I refresh the page is make it stay on the same tab?

I use javascript, html and pl/sql
 <-- Java script -->
function showPanel(panelNum){
     //hide visible panel, show selected panel, set tab
           if (currentPanel != null) {
          hidePanel();
     }
         document.getElementById("panel"+panelNum).style.visibility = "visible";
        currentPanel = panelNum;
        setState(panelNum);
     }

     function hidePanel(){
        //hide visible panel, unhilite tab
        document.getElementById("panel"+currentPanel).style.visibility = "hidden";
        document.getElementById("tab"+currentPanel).style.backgroundColor = "#ffffff";
        Document.getElementById("tab"+currentPanel).style.color = "navy";
     }

     function setState(tabNum){
          if(tabNum==currentPanel){
               document.getElementById("tab"+tabNum).style.backgroundColor = "#ddddff";
               document.getElementById("tab"+tabNum).style.color = "red";
          }else{
               document.getElementById("tab"+tabNum).style.backgroundColor = "#ffffff";
               document.getElementById("tab"+tabNum).style.color = "navy";
          }
     }
 
many thanks,
0
denz_1
Asked:
denz_1
1 Solution
 
ZvonkoSystems architectCommented:
A#1: your showpanel(2) needs a state var to allow or disalow swaping the tabs.
A#2: for onLoad you need a showpanel() version WITHOUT tab number to lookup last stored tab number from cookie or from a hidden field.

Show your page for more details.

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now