Solved

CGI and HTML

Posted on 1997-11-02
4
316 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

685 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