Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^3: How to deal with multiple functions served from only one input field?

by ig (Vicar)
on Nov 15, 2013 at 10:13 UTC ( [id://1062729]=note: print w/replies, xml ) Need Help??


in reply to Re^2: How to deal with multiple functions served from only one input field?
in thread How to deal with multiple functions served from only one input field?

Sadly. Entering a domain name in the top field, and hitting enter, does nothing. It doesn't even post a query. However. If I comment out the ip text field, and try it again. It works. ???

If you add a submit button, then Enter will submit the form even if there are multiple text inputs, at least in Firefox 25.0 (the only browser I tested). Without a submit button, Enter submits the form only if there is a single text input but doesn't submit the form if there are multiple text inputs.

The following works for me:

#!/strawberry/perl/bin/perl.exe use strict; use warnings; use CGI; use CGI::Carp qw(fatalsToBrowser); use Net::Whois::Raw; use Net::Whois::ARIN; $Net::Whois::Raw::OMIT_MSG = 1; $Net::Whois::Raw::CACHE_TIME = 1; $Net::Whois::Raw::TIMEOUT = 8; my $q = new CGI; my $domname = $q->param("domname"); my $ip = $q->param("ip"); print "content-type:text/html; charset=utf-8\n\n"; print qq(<!DOCTYPE html> <head><title>igwhois</title></head><body>); print qq( <form method="post"> <fieldset> <label for="domname">Domain: </label><input type="text" name="domn +ame" /><br /> <label for="ip">IP: </label><input type="text" name="ip" /> </fieldset> <input type="submit" value="Submit"> </form> ); if (!$domname) { print ""; } else { my $text = get_whois($domname, undef, "QRY_LAST"); print qq(<pre>); print $text; print qq(</pre>); } my $w = Net::Whois::ARIN->new( host => 'whois.arin.net', port => 43, timeout => 30, ); if (!$ip) { print ""; } else { my $text = $w->query("n + $ip"); print qq(<pre>); print $text; print qq(</pre>); } print qq(</body></html>);
  • Comment on Re^3: How to deal with multiple functions served from only one input field?
  • Download Code

Replies are listed 'Best First'.
Re^4: How to deal with multiple functions served from only one input field?
by taint (Chaplain) on Nov 15, 2013 at 14:36 UTC
    "If you add a submit button, then Enter will submit the form even if there are multiple text inputs, at least in Firefox 25.0 (the only browser I tested)."

    Of course! Because the form becomes an <ISINDEX> without it. I can be such an IDIOT, sometimes. Now I feel stupid again. Thanks alot ig. :)

    Seriously; thanks. I appreciate your pointing out what should have been obvious. This is the problem I stated earlier; I sometimes have an acute knack of making something extremely simple, a needlesslycomplex problem in my head. :P

    +'s to you again. Thank you very much, for your help, ig.

    --Chris

    #!/usr/bin/perl -Tw
    use Perl::Always or die;
    my $perl_version = (5.12.5);
    print $perl_version;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1062729]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2024-04-18 15:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found