Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Perl CGI multiple buttons

by ckant8 (Acolyte)
on Feb 25, 2013 at 11:36 UTC ( #1020497=perlquestion: print w/ replies, xml ) Need Help??
ckant8 has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I have a page to input value and redirect to second page. In second form there are couple of buttons. I want a code call sub routines within second form. I don't want to call another form/page. Basically i am taking input of host name in first page and with the host name i am calling redirecting to second form. Because of telnet session, i want to continue in second page itself. i have created both the pages in cgi. Please someone help me. Thanks Srikanth ------------------------------- Here is my code below: test11.cgi ----------------------------------
#!"D:\Program Files\xampp\perl\bin\perl.exe" use CGI; use CGI::Carp qw(warningsToBrowser fatalsToBrowser); $co = new CGI; print $co->header, $co->start_html(-titile => 'Welcome'), $co->center ($co->h1('Welcome')), $co->start_form ( -method=>'POST', + -action=>"test12.cgi", ), "Enter host name/ip : ", $co->textfield ( -name=>'text1', + -value=>'', ), $co->submit('Submit'), $co->reset, $co->end_form(); $co->end_html; --------- second script test12.cgi --------- #!"D:\Program Files\xampp\perl\bin\perl.exe" use CGI; use CGI::Carp qw(warningsToBrowser fatalsToBrowser); use Net::Telnet; my @output1,@host,@output; my $telnet = new Net::Telnet ( Timeout=>90, Errmode=>'die',input_log=> +'input.log',output_log=>'output.log',Dump_Log=>'dump.log',Option_log= +>'option.log'); $co = CGI->new; print $co->header, $co->start_html(-titile => 'Welcome'), $co->center ($co->h1('Welcome....')); if($co->param()) { @host=$co->param('text1'); } @output1=$telnet->open(@host); if (@output1) { $telnet->waitfor('/login: $/i'); $telnet->print('xxxxx'); $telnet->waitfor('/Password: $/i'); $telnet->print('xxxxxxx'); $telnet->waitfor('/# $/i'); print "Connected to host : <b>@host</b>", $co->start_form ( -action=>"&ver1()"); print qq(<input type="submit" name="bsubmit" value="State" +>\n); print "<hr>", $co->end_form(); sub ver1() { print "test"; } } print $co->end_html;

Comment on Perl CGI multiple buttons
Download Code
Re: Perl CGI multiple buttons
by Anonymous Monk on Feb 25, 2013 at 12:03 UTC
    Ok ... So you have a page and ... sorry lost you after that!
Re: Perl CGI multiple buttons (http/ajax)
by Anonymous Monk on Feb 25, 2013 at 12:18 UTC
      Confused...

        Please be more specific, if you're generally confused there's not a lot we can do to help. If you have something specific that you don't understand then perhaps you need to do some research (as suggested) into the technologies/concepts involved. If you have something worth while to say please do so. Read and understand How do I post a question effectively? and PerlMonks for the Absolute Beginner.

Re: Perl CGI multiple buttons
by 7stud (Deacon) on Feb 26, 2013 at 01:55 UTC

    In second form there are couple of buttons. I want a code call sub routines within second form.

    If by that you mean: when a user clicks on one of those buttons, you want to execute some code, then the best solution would be to write some javascript that intercepts the click and executes the code--all within the client browser.

    The javascript code could also send a request to a server which then executes a cgi script and returns the results to the javascript code. You might need to do that if you needed to retrieve some dynamically changing data from a database.

    Because of telnet session, i want to continue in second page itself

    Telnet is a network protocol used on the Internet or local area networks to provide a bidirectional interactive text-oriented communication

    So there are no buttons in telnet.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1020497]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2014-08-23 03:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (172 votes), past polls