469,325 Members | 1,520 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,325 developers. It's quick & easy.

Problem in href url encoding

rajiv07
141 100+
Expand|Select|Wrap|Line Numbers
  1. $cEn_com =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
  2.  
  3. $cEn_art =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
  4.  
  5. $cResult .= "<a href=javascript:open1('/cgi-bin/admin/order_details.pl?ordernumber=ordernum&artist=$cEn_art&company=$cEn_com');>click</a>";
  6.  
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 1562
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
  3.  
hope that helps
Aug 11 '07 #2
miller
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;
  2.  
  3. $cEn_com = uri_escape($cEn_com, '\W');
  4. $cEn_art = uri_escape($cEn_art, '\W');
  5.  
  6. $cResult .= qq{<a href="javascript:open1('/cgi-bin/admin/order_details.pl?ordernumber=ordernum&artist=$cEn_art&company=$cEn_com');">click</a>};
  7.  
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
1 post views Thread by CARIGAR | last post: by
reply views Thread by mdpf | last post: by
reply views Thread by harlem98 | last post: by
reply views Thread by listenups61195 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.