473,398 Members | 2,389 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

problem with apostrophy s in a perl / js dropdown

12
I have dropdown navigation drawing from a database. There is a dropdown box for all the states we have. When you choose a stat, the counties in the next dropdown box are created. My problem is with Prince George's County in Maryland. The 's is the killer. I have tried using the \' to replace this but it doesn't work.

I will show the code and some of the solutions I have tried.

Expand|Select|Wrap|Line Numbers
  1. ...
  2. while($state=$out_sql->fetchrow_array){
  3.         $stateoptions.="<option Value=\"$state\">$state</option>";
  4.         $i=2;
  5.         $countyFill.="subcat$state=new Array()\n";
  6.         $countyFill.="subcat$state\[0\]=new Entry(\"\",\"- Select a County -\")\n";
  7.         $countyFill.="subcat$state\[1\]=new Entry(\"allcounties\",\"Select all Counties\")\n";
  8. .......connect to the database...........
  9.         while($county=$out_sql->fetchrow_array){
  10.             $countyFill.="subcat$state\[$i\]=new Entry(\"$county\",\"$county\")\n";
  11.             $i++;
  12.             }
  13.  
[RESULT]
subcatMD=new Array()
subcatMD[0]=new Entry("","- Select a County -")
subcatMD[1]=new Entry("allcounties","Select all Counties")
subcatMD[2]=new Entry("Harford","Harford")
subcatMD[3]=new Entry("Howard","Howard")
subcatMD[4]=new Entry("Montgomery","Montgomery")
subcatMD[5]=new Entry("Prince George's","Prince George's")
subcatMD[6]=new Entry("Worcester","Worcester")
[/RESULT]

This calls an error Expected ')'

------------------------------
I tried adding code to replace the ' with the \'
$county =~ s/\'/\\\'/;

but then my RESULT is
subcatMD[5]=new Entry("Prince George\'s","Prince George\'s")
Which still doesn't work.
-------------------------------------------------------
I suggested just removing the ' and making it Prince Georges but my boss nixed that. I guess the folks in Prince George's county care about such things.

I tried subing &#39 for the ' but got "Prince George&#39s"

I tried all sorts of other things but still have had no luck.

I would appreciate any ideas you might have.

Thanks,
Brita
Oct 1 '07 #1
7 1554
eWish
971 Expert 512MB
I would try and use qq{}; Which is equivalent to double quoting and interpolates. Anything that falls in-between should not need to be escaped.
Expand|Select|Wrap|Line Numbers
  1. $countyFill.=qq{subcat$state[$i]=new Entry("$county","$county")\n};
Oct 1 '07 #2
KevinADC
4,059 Expert 2GB
the error is a javascript error, no? You may have to add another backslash to get it to be a literal \' in the javascript. So in your perl code use: \\'
Oct 2 '07 #3
KevinADC
4,059 Expert 2GB
I would try and use qq{}; Which is equivalent to double quoting and interpolates. Anything that falls in-between should not need to be escaped.
Expand|Select|Wrap|Line Numbers
  1. $countyFill.=qq{subcat$state[$i]=new Entry("$county","$county")\n};
"expert" rank after only 23 posts? Who'd you pay? ;)
Oct 2 '07 #4
numberwhun
3,509 Expert Mod 2GB
"expert" rank after only 23 posts? Who'd you pay? ;)
Hey, you helped endorse him! ;-|)
Oct 2 '07 #5
KevinADC
4,059 Expert 2GB
Hey, you helped endorse him! ;-|)

Us Kevins have to stick together. :)
Oct 2 '07 #6
Brita
12
Thanks for all your help guys. ;-))

Brita
Oct 2 '07 #7
Kelicula
176 Expert 100+
Thanks for all your help guys. ;-))

Brita
Well... Did you get it to work?!

Ha!

Just curious, I may need to know what did work soon...

tks!
Oct 13 '07 #8

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

Similar topics

10
by: DataBard007 | last post by:
Hello Access Gurus: I use Win98SE and Access97. I just built a simple Access97 application which holds all contact information for my personal contacts, such as first name, last name, address,...
0
by: E . | last post by:
I seem to be getting nowhere with this problem here is the situation. I have a webform with a data grid populated with the results of a table that has only 3 fields. Then below that are 1...
0
by: Manish | last post by:
Hi All, I'm having this problem I hope someone can help provide a solution for it :) I've this dropdown list box in a usercontrol which I'm populating from the database (it's viewstate property...
0
by: Mike | last post by:
Hi all! I have an OwnerDrawVariable ComboBox in .net. In the ComboBox DropDown event I display another control - works well. In the control's Leave event I remove the control - works well. So...
2
by: Mike Collins | last post by:
I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. It was asked by someone else what the autopostback was...
2
by: Brian | last post by:
Hi, All, I have two dropdown lists in itemtemplate in a datagrid. for example, dropA and dropB. also, for the dropdown, I set < Runat="server" AutoPostBack="True" OnSelectedIndexChanged="some...
2
by: sameer | last post by:
Hi guys, thanks in advance. trying to implement some multithreading here : VS 2003 VB.net winforms I have a dropdown on a form which has list of vendors, when the user selects a vendor...
5
by: arnabit | last post by:
I have created a dropdown ,which is inside a panel and the panel is inside a place holder . the panel and the dropdown is created dynamically. I do have a button when the button is clicked i am...
1
by: kanishka1213 | last post by:
#!/activeperl/perl/bin/perl use CGI qw(:standard); print "Content-type: text/html\n\n"; print <<EndOfHTML; <html> <head> <script language="javascript" type="text/javascript">
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.