Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

(ar0n) Re: Loading $_ as checkbox value when $_ has double quotes in its value

by ar0n (Priest)
on Dec 04, 2001 at 11:23 UTC ( [id://129285]=note: print w/replies, xml ) Need Help??


in reply to Loading $_ as checkbox value when $_ has double quotes in its value

s/"/&quot;/g; s/'/&apos;/g; print qq|<input type="checkbox" name="box$post_number" value="$_">|;

This works for both double as well as single quotes.

update: Err, no. It will render normally. Since &apos; and &quot; are simply entities browsers should render (as form values and as text), so dws' example where he assigns $_ to another variable isn't necessary at all.

[ ar0n -- want job (boston) ]

Replies are listed 'Best First'.
Re: (ar0n) Re: Loading $_ as checkbox value when $_ has double quotes in its value
by jerrygarciuh (Curate) on Dec 04, 2001 at 11:29 UTC
    ar0n,
    Won't doing it that way screw the HTML? I mean it escapes the quotes around the font face for instance, no? Jeez it is too late for rational thought, I'll try it in the morning. Thx!
    jg
    _____________________________________________________
    If it gets a little bit out of hand sometimes, don't let it fool you into thinkin' you don't care.TvZ
      Won't doing it that way screw the HTML?

      In that case don't make $_ do double-duty. Instead, try

      my $dequoted = $_; $dequoted =~ s/"/&quot;/g; print qq|<input type="checkbox" name="box$post_number" value="$dequote +d">|;

        Don't quote your output at all print "stuff";

        Use a here document instead then you can put anything you fancy in it.

        print <<HTML; Delete This Post? \n <input type=checkbox name="box$post_number" value=" $_ "<p +> $_<hr>\n<p>\n<br><br><br>\n|; HTML

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-03-28 22:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found