Solved

If (CheckBox not Checked) then?

Posted on 2002-04-19
6
194 Views
Last Modified: 2010-04-09
User clicks next button;

If (CheckBox not Checked) then
     Message;
     Return


Got HTML or script for this?

If script preferably VB or perl.

Thanx in advance,

Greg

0
Comment
Question by:SurferJoe
  • 3
  • 2
6 Comments
 
LVL 2

Accepted Solution

by:
coreyit earned 20 total points
ID: 6954583
While I would not recommend that you rely on a client-side solution, here is one:

<form onsubmit="if( ! this.CHECKBOXNAME.checked ) { alert( 'To continue, you must check the checkbox!' ); }; return( this.CHECKBOXNAME.checked );">

On the server side, you should be able to check the request for the presence of the checkbox value. If it exists, the useer checked it and you can forward to the next page. If it does not exist, return to the start page with an error message.

-corey
0
 
LVL 4

Author Comment

by:SurferJoe
ID: 6954649
If you have a server side example I'll give you bonus points accordingly, else if this works you win for being first.

I just what to be sure the user has read and accepts our subscriber service agreement before continuing.

Thanx for the prompt response,

Greg

0
 
LVL 2

Expert Comment

by:coreyit
ID: 6955141
Hmm, I have a Java servlet example. But I don't know what the corresponding VB or Perl would be. In Java:

-------------

  public boolean validate( HttpServletRequest request,
                           HttpServletResponse response )
                    throws ServletException, IOException {
    if( request.getParameter( "CHECKBOXNAME" ) != null &&
        request.getParameter( "CHECKBOXNAME" ).equals( "Yes" ) ) {

      request.setAttribute( "agreed", "true" );
      request.getRequestDispatcher( "ERRORPAGE" ).forward( request, response );
    }
    else {

      request.setAttribute( "errorMsg", "To continue, you must check the checkbox!" );
      request.getRequestDispatcher( "ERRORPAGE" ).forward( request, response );
    }
  }

-------------

I've only done a limited amout of work with Perl. I know that I have some sample code at home that I wrote about a year ago that would probably remind me of what I'd need to know to answer this. If you haven't received a better solution within a few more hours, I'll see if I can drag it up.

-corey
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 22

Expert Comment

by:CJ_S
ID: 6955975
You'd have to do it on the client anyway. The message can only be shown if the script is loaded at the client so the best bet is coreyit's first example.

CJ
0
 
LVL 4

Author Comment

by:SurferJoe
ID: 6956469
Thanx everybody.

Thanx CJ for your comment.

I program in Delphi, dabble with HTML, etc....

0
 
LVL 2

Expert Comment

by:coreyit
ID: 6956985
Oh, I disagree with CJ's comment in this case (not often though). For a server side solution, which is much more reliable, you would essentially generate the page with an error message in it. I know you can do this with Perl, php, etc. as well. But sticking to my Java/JSP example, you would have your agreement page attempt to find a request attribute called errorMsg. If it is found, it's displayed on the web page.

I just found my old Perl stuff. If you like I can try to come up with a comparable example in Perl.

-corey
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Radio button Onclick submit form with validation 5 27
C3-->D3 Line Chart 4 19
SVG Star 4 18
Bootstrap 3 icons 3 12
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Showing your events from Google Calendar in Google Maps Why? I travel all week and I thought it would be ideal if staff in office knew where I was based on my calendar. (OK real reason: my son wanted to see where I would be working, and I thoug…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now