Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Passing Parameters via hyperlink

by o2bwise (Scribe)
on Jun 26, 2013 at 22:18 UTC ( #1040858=perlquestion: print w/ replies, xml ) Need Help??
o2bwise has asked for the wisdom of the Perl Monks concerning the following question:

Hi there,

I am new to using the Mojolicious Perl mod and pretty new doing web design and I am positively stumped trying to pass parameters within a hyperlink. I would rather use the Mojolicious url_for command, but am fine specifying the hyperlink without.

Let's say there are variables $x and $y. Hyperlink text is value for $x.

One of my url_for attempts (although I see I am not encapsulating the href value in quotes:

<a href= <%= url_for("foo")%><%= x=$x&y=$y> %>$x</a>

And here is an attempt without url_for:

<%= <a href="http://foo.com/foo?x=$x&y=$y">%><%= $x %></a>

Actually, in one of my attempts (here just trying to pass one variable), I get to the url I want and I think the text of the url shows the correct syntax for passing a variable, but I do not see it. This is less generic, but:

<tr><td><a href="http://torstore01.omc.foo.com:443/device_list?id=<%= +$id %>"><%= $id %></a></td></tr>

Here is the url it goes to:

http://torstore01.omc.foo.com:443/device_list?id=568185

(Looks good to me!) And I have this asking for the parameter:

% use Data::Dumper; % use CGI; % my $cgi = new CGI; % my %input = $cgi->param(); % layout 'default'; % my $dir = '/home/tony/outage-management/testing'; % open (TEST,">$dir/device_list_test.txt"); % print TEST '%input: ', Dumper(%input);

And file device_list_test.txt contains

%input:

(The hash is empty.) Maybe I am passing the variable, but I am doing something wrong at the place where I try to fetch it?

For all I know, I am trying to do something in ways that cannot be done. Would sure appreciate a hand.

Signed,

{frazzled}

Comment on Passing Parameters via hyperlink
Select or Download Code
Re: Passing Parameters via hyperlink
by sundialsvc4 (Monsignor) on Jun 26, 2013 at 23:37 UTC

    My first glance, when compared against this documentation page for CGI.pm, is that you need to use an array not a hash here.

    Now, what this has to do with Mojolicious, I don’t know...

    Also, check the usual suspects:   use a client-side debugger to verify what the URL string actually contains (“trust, but verify ...”), and likewise what CGI thinks it received.

Re: Passing Parameters via hyperlink
by davido (Archbishop) on Jun 27, 2013 at 00:01 UTC

      C'mon Dave, help me out! ;-)

      Like I said, I am just learning. Other folks at work recommended I use Mojolicious with bootstrap.

      Tony

        Like I said, I am just learning. Other folks at work recommended I use Mojolicious with bootstrap.

        Well, you're already using Mojo, so  $mojoself->req->params->to_hash

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2014-08-31 07:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (294 votes), past polls