Solved

CGI and HTML

Posted on 1997-11-02
4
311 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
ID: 1831062
try document.RefreshForm.submit()
0
 
LVL 7

Accepted Solution

by:
faster earned 100 total points
ID: 1831063
modify the line

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

as:

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

Expert Comment

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

Author Comment

by:daffygirl
ID: 1831065
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
After Effects Random Number, but different each time 5 107
Automating a script for user accounts LINUX 14 73
AutoHotkey ActiveX Component Error 8 87
User profile Size Report 3 74
This article will show, step by step, how to integrate R code into a R Sweave document
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

809 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