Solved

CGI and HTML

Posted on 1997-11-02
4
319 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
[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
  • 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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
The viewer will learn how to count occurrences of each item in an array.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

739 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