Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Classic ASP and Ajax/dhtml

Posted on 2008-10-13
6
Medium Priority
?
855 Views
Last Modified: 2013-11-19
Hi All,

Thanks in advance,

I have  a classic ASP page, i wanted to create a ajax popup with a license agreement and if users accepts passed true boolean  if denies then pass a false boolean back to original page. I also wanted so way of making sure that they scroll down and read the agreement. Is this possible with classic ASP and AJAX, or if you have any other suggestions for making this funtionaly.

Thanks

0
Comment
Question by:dc_zard
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 1

Accepted Solution

by:
timandkids earned 1500 total points
ID: 22706457
Yeah -- you can manipulate the form fields or ID'd objects on the parent page from the child page using javascript. I think the syntax is something like this, where the script is placed in the child page and "self.opener" represents the parent page:

self.opener.forms[0].someElementName.value = document.forms[0].myTextArea.value;

(taken from: http://www.codetoad.com/forum/16_22275.asp)
0
 

Author Comment

by:dc_zard
ID: 22706593
timandkids,

you are suggesting opening a new child window in javascript? that is what the link is describing? Can this be done in AJAX as well or you would recommend this method.
0
 
LVL 1

Expert Comment

by:timandkids
ID: 22712643
If all you're doing is passing data from the one window to the other -- not to a server (like for storage in a database) then plain old javascript is probably the way to go. AJAX would be useful if you need to pass info back and forth from the server to the browser without refreshing (reseting or posting-back) the entire page. Everything you've described looks to me to be entirely client-side, so if it were me I would personally do it all in javascript.

I neglected to address making sure the user scrolls down in the box to verify that they have "read" the agreement... there appears to be a solution for this here, but I haven't tested it:
http://www.27seconds.com/kb/article_view.aspx?id=56 

Please let me know if you are unable to make all of this work for your code, and if you're pulling your hair out with it I'll be happy to try to help more.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:dc_zard
ID: 22715804
Hi,

i would like to create a Timestamp in the database when user accepts the agreement, that is the only information that i would probably pass to the data base. I would assume then i would have to use AJAX.

My question? Is integration between AJAX and classic ASP possible? and it would be helpful if you have some material that i can learn from or if you can point me in the right direction.

Your help is appreciated.


0
 
LVL 1

Expert Comment

by:timandkids
ID: 22716965
Yes -- AJAX and ASP are compatible. What you will do is set up your javascript function that is called when the user accepts the agreement and in that function create an AJAX call to an ASP page that will add the timestamp to the database. You can write an AJAX function to return info to you from the ASP page, like maybe a unique ID from the row in the database or something, or you can write an AJAX function that doesn't care about anything coming back. Additionally, depending on how many variables you want to send to the ASP page via AJAX, you may either append them all to the querystring and send them using GET, or POST them via an XML object. This probably all sounds a lot more complicated than it really is. Here is some code you can look at (something similar to this would go in your pop-up window) and hopefully it will explain everything for you:


<head>
<script language="javascript">
function CreateXMLHttp()
{
 try
 {
  // Firefox, Opera 8.0+, Safari
  return new XMLHttpRequest();
 }
 catch (e)
 {
  // Internet Explorer
  try
  {
   return new ActiveXObject("Msxml2.XMLHTTP");
  }
  catch (e)
  {
   try
   {
    return new ActiveXObject("Microsoft.XMLHTTP");
   }
   catch (e)
   {
    alert("Your browser does not support AJAX!");
    return null;
   }
  }
 }
}
 
 
 
// The following function is an AJAX call to your ASP page.
// Use it if you only have a few small variables or none at all.
function AJAXCallUsingGET()
{
 var xmlHttp = CreateXMLHttp();
 
 // The random variable is to keep the call from caching the previous request
 var day = new Date();
 var RandomID = day.getTime();
 
 // Tack on whatever querystring variables you like here
 var PagePath = "MyASPPage.asp?rand=" + RandomID + "&somevariable=12345";
 
 xmlHttp.onreadystatechange=function()
 {
  if(xmlHttp.readyState==4)
  {
   strText = xmlHttp.responseText;
   // If you want, you can do something with the
   // text (strText) that you pass back from the ASP page (using Response.Write) right here
 
   // This is also where you would want to put the call to the opener page.
  }
 }
 
 xmlHttp.open("GET",PagePath,true);
 xmlHttp.send(null);
}
 
 
 
// The following function is an AJAX call to your ASP page.
// Use it if you have a bunch of variables or some really big ones, like textarea content.
// I'm not exactly sure how to use ASP to get the data from the XML file you would post here,
// but I'm sure there's some way to do it, and it doesn't sound like you'll need to anyway since
// all you're doing is writing a timestamp. You probably don't need this function.
function AJAX CallUsingPOST()
{
 var VariableA = document.getElementById('txtVariableA').value;
 var SecondVariable = document.getElementById('txtSecondVariable').value;
 var VariableNumber3 = document.getElementById('txtVariableNumber3').value;
 
 // There are other ways to write the following, but this seems to work for all browsers
 var xml = '<?xml version="1.0"?><datarequest><request ';
 xml = xml + 'VariableA="' + VariableA + '" ';
 xml = xml + 'SecondVariable="' + SecondVariable + '" ';
 xml = xml + 'VariableNumber3="' + VariableNumber3 + '" ';
 xml = xml + '/></datarequest>';
 
 var xmlHttp = CreateXMLHttp();
 
 // The random variable is to keep the call from caching the previous request
 var day = new Date();
 var RandomID = day.getTime();
 
 // You can put querystring variables here if you like
 xmlHttp.open("POST", "MyASPPage.asp?rand=" + RandomID + "&somevariable=12345", false);
 xmlHttp.setRequestHeader('content-type', 'text/xml');
 xmlHttp.send(xml);
 
 if(xmlHttp.responseText != "")
 {
  strText = xmlHttp.responseText;
  // If you want, you can do something with the
  // text (strText) that you pass back from the ASP page right here
 
  // This is also where you would want to put the call to the opener page.
 }
 else
 {
  // Error Checking
 }
 
}
</script>
</head>
<body>
<form>
 <input type="button" value="I Accept" onclick="AJAXCallUsingGET();" />
</form>
</body>

Open in new window

0
 
LVL 1

Expert Comment

by:timandkids
ID: 22716977
There is a great AJAX tutorial here:
http://www.w3schools.com/Ajax/Default.Asp
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

OverviewThis article demonstrates a simple search form using AJAX. The purpose of the article is to demonstrate how to use the same code to render a page and javascript (JQuery) and AJAX to make subsequent calls to refine the results. The princip…
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

604 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