Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Regular Coder
    Join Date
    Jan 2011
    Posts
    136
    Thanks
    101
    Thanked 0 Times in 0 Posts

    onclick to open a new http address

    How do I create a button, so that when I click on it, I will be taken to a new http://www.mysite.com/page.html?

    Thank you and sorry for the many questions.

  • #2
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by camaross View Post
    How do I create a button, so that when I click on it, I will be taken to a new http://www.mysite.com/page.html?

    Thank you and sorry for the many questions.
    no problem,

    Code:
    #!/usr/bin/perl
    use strict;
    use warnings;
    use CGI;
    
    my $cg = CGI->new;
    print $cg->header,
       $cg->start_html,
       q(<a href="http://www.mysite.com/page.html" style="font-size: 200%; color: #f00;" title="i want to go home">go planet, go</a>),
       $cg->end_html;
    best regards
    Last edited by oesxyl; 04-07-2011 at 02:27 PM.

  • Users who have thanked oesxyl for this post:

    camaross (04-07-2011)

  • #3
    Regular Coder
    Join Date
    Jan 2011
    Posts
    136
    Thanks
    101
    Thanked 0 Times in 0 Posts
    Thank you very much!

    So I first create a button in the html, and set the form action ="/cgi-bin/xx.cgi", then I save the code you provided in the xx.cgi?

    Thank you.


    Quote Originally Posted by oesxyl View Post
    no problem,

    Code:
    #!/usr/bin/perl
    use strict;
    use warnings;
    use CGI;
    
    my $cg = CGI->new;
    print $cg->header,
       $cg->start_html,
       q(<a href="http://www.mysite.com/page.html" style="font-size: 200%; color: #f00;" title="i want to go home">go planet, go</a>),
       $cg->end_html;
    best regards

  • #4
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by camaross View Post
    Thank you very much!

    So I first create a button in the html, and set the form action ="/cgi-bin/xx.cgi", then I save the code you provided in the xx.cgi?

    Thank you.
    yes, if you build the html with all you want inside, css style, border, whatever, the you can copy the code in the cgi and map html to cgi.
    almost all tags have a cgi correspondent. Don't forget to print the header first.
    see the CGI manual for details.

    Edit: more simple:

    Code:
    print $cgi->header,
       'your html here byte by byte but be carefull to not use \' without escaping';

    best regards
    Last edited by oesxyl; 04-07-2011 at 02:41 PM.

  • Users who have thanked oesxyl for this post:

    camaross (04-07-2011)

  • #5
    Regular Coder
    Join Date
    Jan 2011
    Posts
    136
    Thanks
    101
    Thanked 0 Times in 0 Posts
    Thank you. Another stupid question.

    These codes will be in a sub routine inside my overall code (in the same cgi file though). If 'use strict; use warnings; use CGI' is already available at the beginning of my code, do I need to add them in the subroutine again?




    Quote Originally Posted by oesxyl View Post
    yes, if you build the html with all you want inside, css style, border, whatever, the you can copy the code in the cgi and map html to cgi.
    almost all tags have a cgi correspondent. Don't forget to print the header first.
    see the CGI manual for details.

    Edit: more simple:

    Code:
    print $cgi->header,
       'your html here byte by byte but be carefull to not use \' without escaping';

    best regards

  • #6
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by camaross View Post
    Thank you. Another stupid question.

    These codes will be in a sub routine inside my overall code (in the same cgi file though). If 'use strict; use warnings; use CGI' is already available at the beginning of my code, do I need to add them in the subroutine again?
    no.

    Code:
    sub show_button_page {
       my $scg = shift;
       print $scg->header,
           '......';
    }
    
    my $cg = CGI->new;
    show_button_page($cg);
    Edit:
    i think is clear but just in case, you can reuse the code from a script but you can't display two pages.
    That means that this won't work:

    Code:
    my $cg = CGI->new;
    
    show_button_page($cg);
    
    show_other_page($cg); # <-- wrong, button is already out
                                          # the content will be added to the button page

    best regards
    Last edited by oesxyl; 04-07-2011 at 02:53 PM.

  • Users who have thanked oesxyl for this post:

    camaross (04-07-2011)

  • #7
    Regular Coder
    Join Date
    Jan 2011
    Posts
    136
    Thanks
    101
    Thanked 0 Times in 0 Posts
    Thank you very much for the answers to my MANY questions!!!

  • #8
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by camaross View Post
    Thank you very much for the answers to my MANY questions!!!
    you are welcome,


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •