473,508 Members | 2,107 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

unobtrusive javascript

1 New Member
My code does not work , i cannot find what is wrong with it.
Please help me ! i don not want to use onclick in HTMl file to make unobtrusive javascript.

html

<form id="checkSudoku" action="#">
<input type="button" value="Check" id="check" />
</form>

javascript.

function check()
{
var check=document.getElementById('checkSudoku');
var checkbutton=check.getElementsByTagName('input');
for( var i=0; i < checkbutton.length; i++ ){
checkbutton[i].onclick=function(){
alert("hi");
}
}
May 13 '07 #1
1 1051
iam_clint
1,208 Recognized Expert Top Contributor
Expand|Select|Wrap|Line Numbers
  1.  
  2. <form id="checkSudoku" action="#">
  3. <input type="button" value="Check" id="check" />
  4. </form>
  5.  
  6. <script>
  7. window.onload = check();
  8. function check() {
  9. var check=document.getElementById('checkSudoku');
  10. var checkbutton=check.getElementsByTagName('input');
  11.  
  12. for(i=0;i < checkbutton.length;i++){
  13. checkbutton[i].onclick=function() { alert("hi"); }
  14. }
  15. }
  16. </script>
  17.  
works fine.... i think you were missing a closing } man :) good luck and if you need anything else just ask.
May 13 '07 #2

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

Similar topics

2
3639
by: pantagruel | last post by:
I have an old web application I did where browsers with dynamic capabilities received a drop down menu on the top of the page and a fold out on the left hand side of the page and non-dynamic...
12
1571
by: lorlarz | last post by:
Unobtrusive JavaScript leads to BUILDERS (e.g. drag drop activity builder) Once you totally remove JS from a web page, and learn the shortcuts and efficiencies provided by a library like...
0
7127
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
7501
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
5633
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,...
1
5056
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4713
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3188
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1564
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
768
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
424
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.