Solved

disclaimer on a button

Posted on 2006-11-20
14
443 Views
Last Modified: 2012-05-05
I have an asp database-form where the user select/input and then have to click on a button "view". The results view is opened in a new window. When the user click on the button "view" I wish to display a window/popup that say that they are agree to the disclaimer and if they click ok then the new window is open with the search results and if they do not click ok it does not open the result window. How can I trigger this from the "view" button? can someone show me an example?
0
Comment
Question by:Refael
  • 6
  • 4
  • 2
  • +1
14 Comments
 
LVL 41

Expert Comment

by:HonorGod
ID: 17978941
Make the button a two stage afair.

Have the button action be something like:


<input type='button' value='Query' onClick='agree()'>

with agree() be something like:

  function agree() {
    var ans = confirm( 'Do you agree to the Terms and Conditions?' );
    if ( ans ) {
      ... submit the query
    }
  }
  }
0
 

Author Comment

by:Refael
ID: 17979061
Hi, thanks!

At the moment I have:
============================

<script language="javascript" >
    function showProviders(isPrint)
    {
        document.frmMember.isForPrint.value=isPrint;
        document.frmMember.submit();
    }
</script>
================================

And that 2 buttons

<input type="button" class="button" name="bt1" value="View Results"  onclick="showProviders(0)" />
<input type="button" class="button" name="bt1" value="Print Results"  onclick="showProviders(1)" />

So should I do something like this?
=============================

<script language="javascript" >
    function showProviders(isPrint)
    {
    var ans = confirm( 'Do you agree to the Terms and Conditions?' );
     if ( ans ) {
        document.frmMember.isForPrint.value=isPrint;
        document.frmMember.submit();
    }
</script>
0
 

Author Comment

by:Refael
ID: 17979367
ok i did it the i thought it should be, look above, it actually work but now i face the popup blocker problem which i did not face before adding this code?! is this right?
0
 
LVL 41

Expert Comment

by:HonorGod
ID: 17980605
You shouldn't encounter a popup blocker problem with the confirmation dialog.  Dialog boxes are not considered (or they shouldn't be considered) popups.

btw, since you  don't do anything else with the answer, you could shorten it a bit to be:

<script language="javascript" >
    function showProviders(isPrint)
    {
     if ( confirm( 'Do you agree to the Terms and Conditions?' ) ) {
        document.frmMember.isForPrint.value=isPrint;
        document.frmMember.submit();
    }
</script>
0
 
LVL 41

Accepted Solution

by:
HonorGod earned 200 total points
ID: 17980701
 You may also want to consider having/providing a checkbox on your form that indicates that the user has read and agrees to the Terms and Conditions (T&C).  Then, the showProviders() function should only display the confirmation if the checkbox has not been selected.

  Something like this perhaps:
---------------------------------
<!doctype html public "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title> Terms and Conditions </title>
<script type='text/javascript'>
  function checkIT( formId, agreeId )
  {
    var agree = document.getElementById( agreeId ).checked;
    if ( agree || confirm( 'Do you agree to the Terms and Conditions?' ) ) {
      alert( 'They agree' );
    } else {
      alert( 'They don\'t agree' );
    }
  }
</script>
</head>

<body>
<form id='myForm' action=''>
  <input type='text' size='10'></input>
  <input type='checkbox' id='agree'>I agree</input>
  <input type='button' onclick='checkIT("myForm","agree")' value='Submit'></input>
</form>
</body>
</html>


0
 
LVL 3

Assisted Solution

by:inubis
inubis earned 150 total points
ID: 17981558
Personally I like the approach of putting 'I agree to the T&C" on the button like at:
https://secure.ourproperty.co.uk/signup.html

Alternatively the simple way to confirm things is to put the javascript event on the onsubmit of your form. E.g:

<form target="_blank" onsubmit="return confirm('Do oyu agree to our T&C?');">
  ...
</form>

They click yes, the form submits, they click 'no' and nothing happens. Simple.

-Sam
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:Refael
ID: 17981681
well now i am lost because nothing works!
how can i include this is the script i had?
0
 
LVL 23

Assisted Solution

by:rama_krishna580
rama_krishna580 earned 150 total points
ID: 17981878
Hi,

try this..

<HEAD>

<SCRIPT LANGUAGE="JavaScript">
<!-- Original:  Colin Pc  -->
<!-- Web Site:  http://www.insighteye.com/ -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
function checkCheckBox(f){
if (f.agree.checked == false )
{
alert('Please check the box to continue.');
return false;
}else
return true;
}
//  End -->
</script>

</HEAD>

<!-- STEP TWO: Copy this code into the BODY of your HTML document  -->

<BODY>

<form action="/yourscript.cgi-or-your-page.html" method="POST" onsubmit="return checkCheckBox(this)">
I accept: <input type="checkbox" value="0" name="agree">
<input type="submit" value="Continue Order">
<input type="button" value="Exit" onclick="document.location.href='/index.html';">
</form>

R.K
0
 

Author Comment

by:Refael
ID: 17981905
R.K thanks!!

i getting now lost and more lost...

i have 2 buttons, one for print and one for view.

<input type="button" class="button" name="bt1" value="View Results"  onclick="showProviders(0)" />
<input type="button" class="button" name="bt1" value="Print Results"  onclick="showProviders(1)" />

i have this script already

<script language="javascript" >
    function showProviders(isPrint)
    {
        document.frmMember.isForPrint.value=isPrint;
        document.frmMember.submit();
    }
</script>

you all gave me examples and i am not sure its helpful.



0
 

Author Comment

by:Refael
ID: 17982000
I tried your script again
And it comes with the error:

Microsoft VBScript runtime (0x800A000D)
Type mismatch: 'cint'
actionmember.asp, line 17
Which is actually the page it should open for view and in this page in line 17  it checks for

isForPrint=cint(request.Form("isForPrint"))
0
 

Author Comment

by:Refael
ID: 17982169
I am trying to combine the scripts like this

function checkCheckBox(f){
if (f.agree.checked == false )
{
alert('Please check the box to continue.');
return false;
} else

 function showProviders(isPrint)
    {
        document.frmMember.isForPrint.value=isPrint;
        document.frmMember.submit();
    }
}

I get the

Type mismatch: 'cint'
actionmember.asp, line 17
Which is actually the page it should open for view and in this page in line 17 it checks for
isForPrint=cint(request.Form("isForPrint"))
0
 
LVL 3

Expert Comment

by:inubis
ID: 17983191
What you have looks close.
Let me type what I think you want.

<script>
function showProviders(isPrint)
{
  if(document.frmMember.agree.checked == false)
  {
    alert('You must accept....blah blah blah');
  }
  else
  {
    document.frmMember.isForPrint.value=isPrint
    document.frmMember.submit();
  }
}
</script>

<form method="get" name="frmMember">
  I agree to the T&C<input type="checkbox"  name="agree" /><br>
  <input type="button" class="button" name="bt1" value="View Results"  onclick="showProviders(0)" />
  <input type="button" class="button" name="bt1" value="Print Results"  onclick="showProviders(1)" />
  <input type="hidden" name="isForPrint"  />
</form>

-Sam
0
 
LVL 41

Expert Comment

by:HonorGod
ID: 18179930
Thanks for the 'A', hope things are working out ok for you.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

920 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

16 Experts available now in Live!

Get 1:1 Help Now