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

onClick Event dont function well when a certain space is existed

5
hello there! i had spent lots of time searching and thinking what is the reason why in onClick event like the one below, when a certain space between words is existed, it doesnt function well. can anybody know here the reason. or is there something wrong with my coding. kindly enlighten me if you have some information.

sample 1(just a simple alert message display)
<input type = 'button' Name = 'test1' value='CLICK ME'
onclick = alert('this is only a test')

sample 2(data set on the elements will be call in the function, but it doesnt work since a certain space is existed on the data)
<input type='radio' name='jobvalue' value='" & strInputData & "'" & strWork & " onclick=SelValueJob('" & strInputData & "','" & strInputData2 & "','" & strJOB_ID & "');>"
Jul 18 '07 #1
5 1467
danp129
323 Expert 256MB
hello there! i had spent lots of time searching and thinking what is the reason why in onClick event like the one below, when a certain space between words is existed, it doesnt function well. can anybody know here the reason. or is there something wrong with my coding. kindly enlighten me if you have some information.

sample 1(just a simple alert message display)
<input type = 'button' Name = 'test1' value='CLICK ME'
onclick = alert('this is only a test')

sample 2(data set on the elements will be call in the function, but it doesnt work since a certain space is existed on the data)
<input type='radio' name='jobvalue' value='" & strInputData & "'" & strWork & " onclick=SelValueJob('" & strInputData & "','" & strInputData2 & "','" & strJOB_ID & "');>"
Your onclick events are not quoted.
use
onclick = "alert('this is only a test')"
instead of
onclick = alert('this is only a test')
Jul 18 '07 #2
ceejee
5
i also noticed that when i find some format of writing it in other homepage. thanks for your reply. i just have only a question, why is it even if you dont put a double quotation on it but make sure that there is no space present on the data like the one below work? what explanation can you have about it, their difference for example. i just keep on answering my boss that, that is the format on writing it. any reason you have?

onclick = alert('YAHOOOO')
Jul 18 '07 #3
gits
5,390 Expert Mod 4TB
hi ...

that's a very interesting thing ;) thanks for that question. i had a look over it and discovered the following:

when you do:

[HTML]<body onclick="alert('t est')">
dagshgdjhga
</body>[/HTML]

erverything is fine ... you set an attribute called 'onclick' and assign a value "alert('t est')".

when you do:

[HTML]<body onclick=alert('t est')>
dagshgdjhga
</body>[/HTML]

the parser assumes that you set the attribute called 'onclick' and assign a value
of "alert('t" to it ... and 'est' is parsed as a new attribute. this is why you always should assign attribute-values with quotes!!

you may test my thoughts with mozillas dom-inspector or firefox firebug ;)

kind regards
Jul 18 '07 #4
ceejee
5
thank you for your reply. it enlight me now. i think its better to follow the W3C rules in setting values to any attributes in html. it should be enclose in double quotation always to avoid this kind or trouble.
Jul 19 '07 #5
gits
5,390 Expert Mod 4TB
hi ...

yes of course ... that it what standards are made for ;) ... in case you have more questions post in the forum and we will help you as good as we can ;)

kind regards
Jul 19 '07 #6

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

Similar topics

8
by: KS | last post by:
Just to show some code to show the consept. <img id="date" onclick="javascript:show_calendar();" src="/PlexSysWeb/images/show-calendar.gif" width=20 height=18 border=0> What i want the...
1
by: SomeGei | last post by:
Hey guys.... i have a really big table... and the <tr> tags have onclick/onmouseover events that highlight a row when you drag your mouse over it, and open a popup window when you click anywhere...
2
by: RobG | last post by:
I am trying to dynamically add an onclick to an element, however I just can't get the syntax right. consider the following function: function doClick (evt,x) { // do things with evt and x } ...
4
by: masantha wee | last post by:
Hi all, I am using Firefox and embedding Javascript in html. I understand that we can use mouse events by coding them in the body of html (by creating a button or anything and by adding in the...
5
by: kai | last post by:
Hi, In ASP.NET , what is the difference between OnClick and Click events for a button? Because we have button click event, it can trigger events, why we still need OnClick? Please help. ...
11
by: cindy | last post by:
I have a form, has javascript registered so a modal pops up. Button click will close form. Now I need to do an update with modal form data before it closes. I can put a second button and register...
5
by: Fred.Grieco | last post by:
Hi every body, I have a little pb and I'm turning around : function MyFCTN(var1,var2) { var mytable = document.getElementById("myTBL"); for (var i=myTBL.childNodes.length-1; i>0; i--){...
3
by: phish.guy | last post by:
How do I call another event's onclick function from a button press? I have stored information dynamically created in a div onclick function that is not accessible directly by the button, but i...
89
by: Cuthbert | last post by:
After compiling the source code with gcc v.4.1.1, I got a warning message: "/tmp/ccixzSIL.o: In function 'main';ex.c: (.text+0x9a): warning: the 'gets' function is dangerous and should not be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
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
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...

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.