Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 7th, 2012, 02:49 PM
kochaloch's Avatar
kochaloch kochaloch is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 41 kochaloch User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 h 55 m 26 sec
Reputation Power: 6
Cgi page refresh with parameters

Hi,

**UPDATED**

So I have my url variable working but I can't find how to change the value of a variable on click of a button.

Any help would be greatly appreciated

Thanks

Code:
#!/bin/perl 

use CGI;

<form action="/perl/script.pl" method="get">
<input type="text" name="a" value="0">
<input type="submit" value="Submit">
my $getvar = CGI->new();
my $run = $getvar->param('a');
my $q = CGI->new; 

my $go = $q->param('go');

sub print_html{ #prints html stuff } 

sub one{ #does some stuff runs - no matter what } 

sub two{ #does some other stuff } 

##MAIN================= 
print_html; 

$button = qq(<tr><td align=center></td><td><input 

type="Button" name="runsql" value="GO" onclick="?");

print "$button\n"; 

one; 

if( run == 1 ){ two; }

exit;

Last edited by kochaloch : November 8th, 2012 at 03:52 PM.

Reply With Quote
  #2  
Old November 11th, 2012, 10:14 AM
keath's Avatar
keath keath is offline
!~ /m$/
Dev Shed Specialist (4000 - 4499 posts)
 
Join Date: May 2004
Location: Reno, NV
Posts: 4,099 keath User rank is General 12nd Grade (Above 100000 Reputation Level)keath User rank is General 12nd Grade (Above 100000 Reputation Level)keath User rank is General 12nd Grade (Above 100000 Reputation Level)keath User rank is General 12nd Grade (Above 100000 Reputation Level)keath User rank is General 12nd Grade (Above 100000 Reputation Level)keath User rank is General 12nd Grade (Above 100000 Reputation Level)keath User rank is General 12nd Grade (Above 100000 Reputation Level)keath User rank is General 12nd Grade (Above 100000 Reputation Level)keath User rank is General 12nd Grade (Above 100000 Reputation Level)keath User rank is General 12nd Grade (Above 100000 Reputation Level)keath User rank is General 12nd Grade (Above 100000 Reputation Level)keath User rank is General 12nd Grade (Above 100000 Reputation Level)keath User rank is General 12nd Grade (Above 100000 Reputation Level)keath User rank is General 12nd Grade (Above 100000 Reputation Level)keath User rank is General 12nd Grade (Above 100000 Reputation Level)keath User rank is General 12nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Weeks 4 Days 8 h 20 m 20 sec
Reputation Power: 1809
I may be misunderstanding the problem, but if you want to send data back to your script, you would normally use the submit button. The onclick method is typically used to run some javascript, which could in turn submit a request back to your script if you needed to do something complex.
Comments on this post
kochaloch agrees!

Reply With Quote
  #3  
Old November 12th, 2012, 10:33 AM
kochaloch's Avatar
kochaloch kochaloch is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 41 kochaloch User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 h 55 m 26 sec
Reputation Power: 6
Ah OK, ya that makes sense. I solved my problem by directing to a splash page on click of the button and runs some code then redirects back to the main page, but I don't like it and think I going to revisit now.

Thanks for the help!

Reply With Quote
  #4  
Old November 19th, 2012, 02:21 PM
kochaloch's Avatar
kochaloch kochaloch is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 41 kochaloch User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 h 55 m 26 sec
Reputation Power: 6
Updated

OK, so I have everything working but I need to set the query_string on submit of the button, but when It's clicked it just appends a "?" and not the value im trying to append.

Any help appreciated

Code:
#!c:/Perl/bin/perl.exe

use CGI qw(:all -no_xhtml);
use CGI::Carp qw(fatalsToBrowser);

sub testhtml
{
print <<"EOHC";
Content-Type: text/html

<HTML>
	<BODY>
	<h1 align="center"><b>TEST</h1>
	<form action="http://localhost/button.pl?2"
      method="GET">
	<input type="submit" value="Click me">
</form>
	</BODY>
</HTML>
EOHC
}


sub test{

$success = 'yay';
print $success

}

testhtml;

if ($ENV{'QUERY_STRING'} eq "2")
    {

test;

}

Last edited by kochaloch : November 19th, 2012 at 03:39 PM.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > Cgi page refresh with parameters

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap