Solved

CGI and HTML

Posted on 1997-11-02
4
306 Views
Last Modified: 2013-12-25
In this piece of code, I am trying to get the user's reply on whether to proceed with data retrieval.

----------- My C code ------------

// PrintConfirmRefreshPage
//
// Pops up a Confirmation Dialog Box asking whether the
// user to proceed with data retrieval.
//
// Input :
//            Nil
//
// Output :
//            This function gets the user's confirmation on Refresh.
//            If Refresh is required, then call PerformFunction
//            with RefreshFlag set to 1. Else do nothing.
//


#include <stdio.h>

void PrintConfirmRefreshPage()
{
      // print out the header info
      printf("Content-type: text/html\n") ;
      printf("<html>\n");
      printf("<body BGCOLOR=\"#FFFFFF\">\n");

      printf("<FORM NAME=\"RefreshForm\" ACTION=\"https:/xyz/cgi-bin/PerformFunction.exe\" METHOD=\"GET\">\n");

      //      PerformFunction.exe needs the following parameters to execute
      //      the appropriate CGI programs.  Use Hidden so that the fields
      //      will not be displayed on the form.

      printf("<INPUT TYPE=HIDDEN NAME=Function VALUE=GetOnlineInfo>\n");
      printf("<INPUT TYPE=HIDDEN NAME=Refresh VALUE=1>\n");
      printf("</FORM>\n");

      printf("<script language=\"JavaScript\">\n");
      printf("      var ok = null;\n");
      printf("      ok = confirm(\"No data is found in local database. \\r\\nDo you still want to retrieve data from Remote database NOW?\"); \n");
      printf("      if (ok == true) { \n");
      printf("            form.submit(); \n");      // submit the form
      printf("      } \n");
      printf("</script>\n");

      printf("</body>\n);
      printf("</html>\n);

}

-------------- End ---------------

If the OK button is clicked, i would like to execute a CGI program.  I do this by using form.submit().  However, when the program is run and the OK button is clicked, the following error message is displayed:

JavaScript Error
https://servername/dirA/cgi-bin/PerformExecution.exe?Function: GetOnlineInfo
Form is not defined

Is form.submit() being used correctly?  If not, how can i submit the form in the above situation?  I would like to use a confirmation dialog box instead of a submit object (e.g. submit button) in my module.

Any help is greatly appreciated.
0
Comment
Question by:daffygirl
  • 2
4 Comments
 
LVL 84

Expert Comment

by:ozo
Comment Utility
try document.RefreshForm.submit()
0
 
LVL 7

Accepted Solution

by:
faster earned 100 total points
Comment Utility
modify the line

printf(" form.submit(); \n"); // submit the form

as:

printf("document.RefreshForm.submit(); \n");
0
 
LVL 7

Expert Comment

by:faster
Comment Utility
Sorry, I didn't notice ozo's comments.  He actully already gave the right answer.
0
 

Author Comment

by:daffygirl
Comment Utility
Thanks for the help.  It works, but it always seems to give the 'Transfer Interrupted' message first, before the form appears.  But anyway, thanks again!  At least it works now.  :o)
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

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
This article will show, step by step, how to integrate R code into a R Sweave document
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

771 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

14 Experts available now in Live!

Get 1:1 Help Now