tarunkhanna has asked for the wisdom of the Perl Monks concerning the following question:
Above CGI code is calling CheckForEmptyTextbox() function in javascript. But this javascript is in the different file.use CGI; my $co = new CGI; use CGI qw(:standard); use CGI::Carp qw(fatalsToBrowser); use strict; use diagnostics; print $co->header; print $co->start_html(); print $co->start_form(-method => "POST", -action => 'first.cgi'); print $co->h4("Name").$co->p; print $co->textfield({name => 'name', id => 'name'}).$co->p; print $co->submit(-onclick=>"return CheckForEmptyTextbox()"); print $co->reset; print $co->end_form; print $co->end_html;
Javascript
How to call above javascript function from CGI program which is in different files??print <<CheckNameBox; <script language="JavaScript"> function CheckForEmptyTextbox() { if(document.getElementById("name").value=="") { alert ("Emtpy"); return false; } return true; } // end function </script> CheckNameBox
If I paste the above javascript code in the same CGI file, it works.
But what if I want javascript code to be in different file??
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (OT) Javascript with CGI using different files
by marto (Cardinal) on Oct 08, 2011 at 13:24 UTC | |
|
Re: (OT) Javascript with CGI using different files
by aaron_baugher (Curate) on Oct 08, 2011 at 18:27 UTC | |
| |
|
Re: (OT) Javascript with CGI using different files
by Anonymous Monk on Oct 08, 2011 at 12:43 UTC | |
|
Re: (OT) Javascript with CGI using different files
by ww (Archbishop) on Oct 08, 2011 at 13:50 UTC |