471,852 Members | 1,416 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,852 software developers and data experts.

Problem in href url encoding

141 100+
Expand|Select|Wrap|Line Numbers
  1. $cEn_com =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
  3. $cEn_art =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
  5. $cResult .= "<a href=javascript:open1('/cgi-bin/admin/order_details.pl?ordernumber=ordernum&artist=$cEn_art&company=$cEn_com');>click</a>";
Here i have send the encoded parameter with url to javascript open1 function
to diaplay popup window.The open1 function that i am placing in head tag in my html file.

here what my problem is when any one of parameters ( $cEn_com and $cEn_art) has some value the output (OUTPUT is click) is display.If the values are empty string nothing get display.

Is any Idea.
Thank U.
Aug 10 '07 #1
2 1582
i am not entirely sure of your problem, but you could always make sure there was some output, like this

Expand|Select|Wrap|Line Numbers
  1.  if ($cEn_art !~ m{[a-z]}ig || $cEn_com !~ m{[a-z]}ig) {
  2.     #create default response here
hope that helps
Aug 11 '07 #2
1,089 Expert 1GB
There does not appear to be anything wrong with your encoding. However, I would advise you to use the standard module for this type of escaping. It not only helps document what you are trying to do better, but is actually faster sinceu it caches both the replacement translation but also the pattern that you choose to escape:

cpan URI::Escape

Expand|Select|Wrap|Line Numbers
  1. use URI::Escape;
  3. $cEn_com = uri_escape($cEn_com, '\W');
  4. $cEn_art = uri_escape($cEn_art, '\W');
  6. $cResult .= qq{<a href="javascript:open1('/cgi-bin/admin/order_details.pl?ordernumber=ordernum&artist=$cEn_art&company=$cEn_com');">click</a>};
Also, I would advice you to always quote your href's.

Anyway, your problem is not directly related to perl, but is actually either an html or javascript issue. I advise you to ask in the JavaScript forum if the simple quoting of the href above does not fix your problem.

- Miller
Aug 13 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

7 posts views Thread by Harolds | last post: by
reply views Thread by mirek | last post: by
reply views Thread by helldiversafe-news | last post: by
reply views Thread by Satya | last post: by
4 posts views Thread by ceh | last post: by
reply views Thread by NeoPa | last post: by
reply views Thread by YellowAndGreen | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.