Solved

disclaimer on a button

Posted on 2006-11-20
14
442 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
 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
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:Refael
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks for the 'A', hope things are working out ok for you.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

744 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

18 Experts available now in Live!

Get 1:1 Help Now