User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 426,512 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,126 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 224 | Replies: 4
Reply
Join Date: Dec 2007
Posts: 5
Reputation: airwinx is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
airwinx airwinx is offline Offline
Newbie Poster

how to restrict user from click another tabs menu

  #1  
Jul 22nd, 2008
Hi All,
I have 3 horizontal tabs menus with different form to let user key in some infor to the text fields.

When user 1st time access this page, all fields are blank. But if user want to go to the second tab, user must key in some infor at the 1st tabs form. How do I check if user didn't key in anything in the 1st tabs form? I want to force user to key in the 1st tab's form in order to allow user to click the second tab form and 3rd tab form.

What I want is if user didn't key in anything at the 1st tab's form, an alert will prompt out and tell the user to key in the text in the textfield at 1st tab form and save the data into mysql DB. Or else he can't even pressed the second tab form or 3rd tab's form.

How should I proceed with this requirement.

I am using php and mysql for data storage. I think of using javascript to do this but my javascript is knowledge is a bit crappy.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Nov 2007
Location: Arkansas
Posts: 396
Reputation: buddylee17 will become famous soon enough buddylee17 will become famous soon enough 
Rep Power: 2
Solved Threads: 78
buddylee17's Avatar
buddylee17 buddylee17 is offline Offline
Posting Whiz

Re: how to restrict user from click another tabs menu

  #2  
Jul 22nd, 2008
Use the header function to return the user to the first page if the variable from first page isn't filled in.
  1. <?php
  2. if(empty($_POST['var from first page'])){
  3. header ('Location:page1.php');
  4. }
Lost time is never found again.
- Benjamin Franklin
Reply With Quote  
Join Date: Dec 2007
Posts: 5
Reputation: airwinx is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
airwinx airwinx is offline Offline
Newbie Poster

Re: how to restrict user from click another tabs menu

  #3  
Jul 22nd, 2008
I using yui tabview to show the tab menu. All the form is within the same page.

Here is the sample of how my tab menu look like: http://developer.yahoo.com/yui/examp...rommarkup.html

So when user click 1st tab and then to next tab menu, i need to verify if user is allow to click 2nd tab. Or else force user back to 1st tab. Each tab will have a <div id=tab1>content</div>.

Maybe I should said how to anchor back to the 1st tab content using javascript?

Buddylee17, i try ur method but it juz somehow refresh the whole page.
Last edited by airwinx : Jul 22nd, 2008 at 8:58 pm.
Reply With Quote  
Join Date: Nov 2007
Location: Las Vegas, Nevada
Posts: 83
Reputation: johnsquibb is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 14
johnsquibb's Avatar
johnsquibb johnsquibb is offline Offline
Junior Poster in Training

Re: how to restrict user from click another tabs menu

  #4  
Jul 23rd, 2008
JavaScript would be the way to go.
You'll probably get better help in the JavaScript/AJAX/DHTML forum on this one.
The End
Reply With Quote  
Join Date: Nov 2007
Location: Arkansas
Posts: 396
Reputation: buddylee17 will become famous soon enough buddylee17 will become famous soon enough 
Rep Power: 2
Solved Threads: 78
buddylee17's Avatar
buddylee17 buddylee17 is offline Offline
Posting Whiz

Re: how to restrict user from click another tabs menu

  #5  
Jul 23rd, 2008
Yeah you'll definitely want some JavaScript incorporated. What I would do:
Disable tabs 2 and 3.
Use onclick handler to send the first form to a php script via an xmlhttprequest(AJAX). If the form validates, send the contents of the second form back and populate with innerHTML and enable the second tab. Also, do the same for the third. If you are not familiar with AJAX, do what john said and repost in the JavaScript/AJAX/DHTML forum.

-notice I said onclick handler. That's only because an onsubmit will cause a page refresh and the form change will not be seamless.
Lost time is never found again.
- Benjamin Franklin
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the PHP Forum

All times are GMT -4. The time now is 5:57 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC