473,387 Members | 1,678 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,387 software developers and data experts.

spaces in html selects

Hi,

My html page contains an array of objects:

[{name:'Admiral Nelson', address:'Trafalgar Square' , city:'London'}, { etc
}]

Please notice the space between Admiral and Nelson.

My html page also contains a <select> with names, among them Karl Marx.

An OnChange event passes the selectvalue to a function which iterates over
the array in search of the selectvalue.
When there are no spaces it finds a match, so my code is basically OK, but
when there are spaces, it doesn't.

thx for any help

Ward

May 7 '06 #1
9 1204
King Albert <ki**********@forpresident.com> wrote in
news:Xn**********************************@195.130. 132.70:
Hi,

My html page contains an array of objects:

[{name:'Admiral Nelson', address:'Trafalgar Square' , city:'London'},
{ etc }]

Please notice the space between Admiral and Nelson.

My html page also contains a <select> with names, among them Karl
Marx.

An OnChange event passes the selectvalue to a function which iterates
over the array in search of the selectvalue.
When there are no spaces it finds a match, so my code is basically OK,
but when there are spaces, it doesn't.

thx for any help

Ward


typo : replace Karl Marx with Admiral Nelson
I'm doing a phone book app
May 7 '06 #2
"King Albert" <ki**********@forpresident.com> wrote in message
news:Xn**********************************@195.130. 132.70...
Hi,

My html page contains an array of objects:

[{name:'Admiral Nelson', address:'Trafalgar Square' , city:'London'}, { etc }]

Please notice the space between Admiral and Nelson.

My html page also contains a <select> with names, among them Karl Marx.

An OnChange event passes the selectvalue to a function which iterates over
the array in search of the selectvalue.
When there are no spaces it finds a match, so my code is basically OK, but
when there are spaces, it doesn't.

Perhaps if you showed us your function....
May 7 '06 #3
King Albert wrote:
An OnChange event passes the selectvalue to a function which iterates
over the array in search of the selectvalue.
When there are no spaces it finds a match, so my code is basically
OK, but when there are spaces, it doesn't.


If your code is the problem, it would probably make sense to post the code
here, no? :)

Take your current non-working example and strip away as much as possible to
make a minimal page/code which still exhibits the problem.
This will accomplish two things:
1) Someone trying to help you can focus on the real problem and not be
distracted by other unimportant details
2) You will likely find the source of the problem yourself during the
minimization process.

Good luck!

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
May 7 '06 #4
King Albert <ki**********@forpresident.com> wrote in
news:Xn**********************************@195.130. 132.70:
Hi,

My html page contains an array of objects:

[{name:'Admiral Nelson', address:'Trafalgar Square' , city:'London'},
{ etc }]

Please notice the space between Admiral and Nelson.

My html page also contains a <select> with names, among them Karl
Marx.

An OnChange event passes the selectvalue to a function which iterates
over the array in search of the selectvalue.
When there are no spaces it finds a match, so my code is basically OK,
but when there are spaces, it doesn't.

thx for any help

Ward


Ok,

here's the URL : http://users.telenet.be/namibia

Both css and JS are part of index.html

Target browser is FF 1.5, IE6 won't do

In the rightmost select, try "Brugge" and "De Haan".
De Haan won't work.

thx

Ward
May 8 '06 #5
Ward Germonpré wrote:
here's the URL : http://users.telenet.be/namibia
That is _not_ a simple test case.

Remove everything that isn't related to the problem until you get the
smallest possible page which still doesn't work.
In the rightmost select, try "Brugge" and "De Haan".
De Haan won't work.


I don't know what "won't work" means, since I don't know what is supposed to
happen. I get an error when I choose anything in the right-most select.

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
May 8 '06 #6
"Matt Kruse" <ne********@mattkruse.com> wrote in
news:e3*********@news1.newsguy.com:
Ward Germonpré wrote:
here's the URL : http://users.telenet.be/namibia


That is _not_ a simple test case.

Remove everything that isn't related to the problem until you get the
smallest possible page which still doesn't work.
In the rightmost select, try "Brugge" and "De Haan".
De Haan won't work.


I don't know what "won't work" means, since I don't know what is
supposed to happen. I get an error when I choose anything in the
right-most select.


Hi Matt,

The rightmost dropdownbox selects a city, if you choose one my script
creates a DOM table with all collegues that live in that city. In fact,
any dropdown box you choose or any letters you type in the input boxes
should yield a DOM table.

It works fine on FF 1.5, as long as you don't choose a city that has a
space in its name like "De Haan".

What's bizarre is that this problem only occurs on my rightmost
selectbox, the other selectboxes don't have it even if you select sth
with spaces in it. And the eventhandler is the same !
What error are you getting ?

thx

Ward
May 8 '06 #7
In the last select input tag you are not "Quoting" the values with
spaces:
<option value=De Haan>De Haan</option>
should be:
<option value="De Haan">De Haan</option>
the option tag is seeing the attribute value equalling "De" and another
attribute of "Haan" with no value.

The second to last select with spaces works because the values
themselves don't contain the spaces:
<option value=DSEC>directie assistent</option>
Ward Germonpré wrote:
King Albert <ki**********@forpresident.com> wrote in
news:Xn**********************************@195.130. 132.70:
Hi,

My html page contains an array of objects:

[{name:'Admiral Nelson', address:'Trafalgar Square' , city:'London'},
{ etc }]

Please notice the space between Admiral and Nelson.

My html page also contains a <select> with names, among them Karl
Marx.

An OnChange event passes the selectvalue to a function which iterates
over the array in search of the selectvalue.
When there are no spaces it finds a match, so my code is basically OK,
but when there are spaces, it doesn't.

thx for any help

Ward


Ok,

here's the URL : http://users.telenet.be/namibia

Both css and JS are part of index.html

Target browser is FF 1.5, IE6 won't do

In the rightmost select, try "Brugge" and "De Haan".
De Haan won't work.

thx

Ward


May 8 '06 #8
br****@gmail.com wrote in news:1147095720.595198.233580
@j73g2000cwa.googlegroups.com:
In the last select input tag you are not "Quoting" the values with
spaces:
<option value=De Haan>De Haan</option>
should be:
<option value="De Haan">De Haan</option>
the option tag is seeing the attribute value equalling "De" and another
attribute of "Haan" with no value.

The second to last select with spaces works because the values
themselves don't contain the spaces:
<option value=DSEC>directie assistent</option>


Right. Works!
I knew it had to be something basic.
The script that populates the selects was one of the first things I did
in PHP. So much for code re-use :)
Thank you !

Ward
May 8 '06 #9
JRS: In article <Xn**********************************@195.130.132. 70>,
dated Mon, 8 May 2006 12:51:20 remote, seen in
news:comp.lang.javascript, Ward Germonpré <ki**********@forpresident.com
posted :

It works fine on FF 1.5, as long as you don't choose a city that has a
space in its name like "De Haan".


Remember to test it with s'Hertogenbosch / s'Gravenhage, Westward Ho!,
København, Ashby-de-la-Zouch, and cities whose names contain accented
characters, unless you can be sure that your list will never need to
include any of those.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
May 10 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Nathan Sokalski | last post by:
I am using ASP to read code from a text file that I am displaying on my page. Because I do not want the code from the text file to be executed, I used the Server.HTMLEncode() method to display it...
3
by: larry | last post by:
Hi, I am a newbie to Internet programming. I have some questions about spacing in HTML control names and subsequently being able to access these input elements in JavaScript If you don't have...
2
by: Eric Sabine | last post by:
I am filling a drop down list from a dataset. The resultset contains data like this Joe Smith Accounting Mike Collins Engineering Joe Walter Engineering etc. The...
3
by: Prince | last post by:
I have some <RequiredFieldValidator> on my page and everything works fine except that there are lots of white spaces between the web server controls that are being validated. I've set the Display...
14
by: Sergei Riaguzov | last post by:
I have a very strange behaviour with POST keys. Consider a test: wtf.html: === Cut === <form action="eh.php" method="POST">     <input type="checkbox" name="many spaces and. . dots. . "/>...
4
by: Manuel Reimer | last post by:
Hello, my problem is that spaces are always reduced to the size of one in html. I need some trick to make all spaces in a line visible. Something like this is possible with "<pre>" in HTML,...
135
by: Xah Lee | last post by:
Tabs versus Spaces in Source Code Xah Lee, 2006-05-13 In coding a computer program, there's often the choices of tabs or spaces for code indentation. There is a large amount of confusion about...
2
by: dachrist28 | last post by:
I am trying to populate a listbox with data that is pulled from a sql query. Here is my C# code behind the page: sqlConn1.Open(); SqlCommand sqlComm2 = new SqlCommand("SElECT...
6
by: Adrian | last post by:
How do I stop spaces from disappearing in an email I make up in an application? I found that \r\n has to be replaced by other characters, so presumably spaces have to be replaced as well: but by...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.