Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

passing args in html

by daddyo (Initiate)
on Jan 27, 2002 at 00:00 UTC ( #141821=perlquestion: print w/replies, xml ) Need Help??
daddyo has asked for the wisdom of the Perl Monks concerning the following question:

how/is it possible to pass arguments to a cgi script in html: <img src = "skrit.cgi 1"> so that argv[0]=1? it works ok without the arg ... <img src = "skrit.cgi">

Replies are listed 'Best First'.
Re: passing args in html
by BazB (Priest) on Jan 27, 2002 at 00:14 UTC

    I'm not sure if this is actually a Perl/CGI question - it's more HTTP and HTML - if you want to pass arguments to another page use:

    <a href="random_page.cgi?arg1=foo&arg2=bar&arg3=baz">Random Page</a>
    or
    <img src="random_page2.cgi?arg1=foo&arg2=bar&arg3=baz">
    You get the idea.

    It's the same idea whether it's a perl script, php page, ASP *Gaaak* page, or whatever.
    For an example of this, look at almost any page in the Monastery...

    Pulling out the arguments you pass to your script in this fashion (or via the POST method) will require the modules belg4mit mentioned.

    Update: wog++. Taking wog's post a bit further, it's probably a good idea to do URL Escaping - pass all strings like the URLs I've written above through URI::Escape or CGI's escape() in order to correctly handle difficult arguments.
    It's something I've got into the habit of - IMHO it's worth having a sub urlEncode in bigger systems.

      The &s in URLs should be written &amp; and &#38; in HTML. (reference). If the CGI, etc. you are calling supports it, it would probably be cleaner to use ; instead of & as the parameter seperator. (CGI.pm supports this.)
      Thanks for sharing your wisdom, Masters of Perl.
Re: passing args in html
by belg4mit (Prior) on Jan 27, 2002 at 00:06 UTC
    It's possible (IIRC), but you'd be much better off boning up on CGI and using PATHINFO or GET. See CGI and CGI::Lite.

    UPDATE: Additionally, passing arguments directly could be a Bad Thing. Passing parameters via another means requires additional processing to extract them, this is a Good Thing because while you are doing this you might as well go "whole hog"(?) and untaint and validate the data. Just as a general rule.

    --
    perl -pe "s/\b;([st])/'\1/mg"

      I'd also go even further and recommend studying basic html and web forms. OReilly's HTML book is a good start.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://141821]
Approved by root
help
Chatterbox?
[Discipulus]: so every library (js) to sdelect and modify the id parameters can be good.
[Discipulus]: I never understood something: I can on the fly modify the XML structure of the SVG using for example XML::Twig ?
[Corion]: Discipulus: If you want to rewrite the SVG, then yes, something like XML::Twig should be enough. I would try to not modify the SVG but only modify the display, but so far I haven't convinced IE to change the style...
Corion gives up
[Discipulus]: ah! so you mean if i need a static image i can use Twig, if on the fly better css selector and mody attrs (jquery?), rigth?
[LanX]: not sure what you guys are taking about, but a DOM manipulation in JS shouldn't be difficult
[Corion]: Discipulus: Yeah, that's what I would try (but so far, I can't even change the colors manually in the SVG, which is why I gave up ;) )
Discipulus bad sign..

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (13)
As of 2017-03-23 09:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (285 votes). Check out past polls.