Jump to content
WesleyA

checkbox validation with 2 pages.

Recommended Posts

Can someone give an example of a php script that lets a form with checkbox input choose between 2 different pages when it is checked or not.

 

Actually the dilemma is that the action attribute is sending form data to another pages (2 pages) - but dont know what code to use - .

 

So if the checkbox isnt checked a third page should load in the browser.

Share this post


Link to post
Share on other sites

put the code for each page in its own include, and then use the value of the checkbox to include the appropriate code:

if (!empty($_POST['mycheckbox'])){   include '../page1.inc';}else{    include '../page2.inc';}  

Or just resolve the page that that should be loaded client side and alter the action with javascript.

Share this post


Link to post
Share on other sites

So you want the user to have the ability to open two pages in different tabs/windows or both in one page? which the checkbox would be the correct input type to use, OR give the user the ability to select one or the other where input type radio should be used where also the third page could be the default.If you use cobol PHP method i should check if file exits before attempting to include.

Share this post


Link to post
Share on other sites

Yeah my idea is that 2 pages are a good solution.

 

I tried to add the code with include but it doesnt open the pages in a new window or new tab which I would rather have.

 

( I heard of COBOL as a very old programming language as I'm born in the sixties and COBOL is from that period or so, but now I program PHP, as far as I know I only use the most common library of instructions. I now have WAMP installed I dont use tools or API's, dialect etc. at the moment.)

Edited by WesleyA

Share this post


Link to post
Share on other sites

When i said cobol i was refering to COBOLdinosaur.

Yeah my idea is that 2 pages are a good solution.

Still does not tell me from previous post what you are looking for? 2 or more page could be use in any of those options mentioned.

Share this post


Link to post
Share on other sites

 

When i said cobol i was refering to COBOLdinosaur.

 

 

:rofl: Its Okay I am actually older than COBOL and I even beat the introduction of ENIAC by a little bit.

Share this post


Link to post
Share on other sites

When i said cobol i was refering to COBOLdinosaur.Still does not tell me from previous post what you are looking for? 2 or more page could be use in any of those options mentioned.

 

But include makes that the page content is showed on the same page.

Share this post


Link to post
Share on other sites

AaaaarrrggggghhhThe user has the option with two checkboxes to select ALL, i.e BOTH!Is that what you want?IF YESDo you want the user to have the ability to open two pages in DIFFERENT tabs/windows/pages or BOTH in same one page?IF NOthen you should be using radio buttons where only one page can be selected.

Share this post


Link to post
Share on other sites

Im looking for a solution to direct the visitor to a page so they can have a message that the checkbox should be checked.

 

Submit action offers the possibility to direct someone to one page. (or am i wrong?)

 

The idea is that the decision whether the checkbox is checked has to be made in advance. If checked it shoud go on using the submit action

 

(if this is the only solution ???)

 

It works like this: the user gets a list of several choices (taken from a list of mysql database tables) and they have to check. Only 1 is allowed to be chosen. You have to choose one (not 2 or 5 but 1) else the parser gives an error and/or nothing will be added to the database. If the checkbox is chosen the user can add records to the table.

 

What I want is actually free and is also a matter of possibilties there are with HTML/PHP (not javascript). So they can be sent to an error_page and the completed page was one option. Maybe its also an option to have it echoed on the same page but it depends on what is possible and how that is done.

 

What is the difference in approach between these 2 different pieces of script?

Edited by WesleyA

Share this post


Link to post
Share on other sites

Like i keep repeating, for one option use radio buttons, you can set a pre checked option for when the user does not select any, or process this using php if no selections are made.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...