SitePoint Sponsor |
|
User Tag List
Results 1 to 4 of 4
Thread: What is the problem with this?
-
Jan 11, 2007, 23:25 #1
- Join Date
- Aug 2006
- Posts
- 32
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
What is the problem with this?
I cjust create small version of what i'm trying to do. basicly 1st table has a hidden value which is '1' and second table has 2 diffrent values. onclick function second table send the value to 1st table but i need to check if the passed value is same as hidden value. Can some one tell me where is the error. i am sure that error is in "function cell(a)".
PHP Code:<script>
window.onload=function getid() {
var myId;
obj=document.getElementsByTagName('th');
for(c=0;c<obj.length;c++) {
if(obj[c].id!='') {
obj[c].onclick=function getid() {
myId=this.id;
e = document.getElementById(myId);
var thestyle= eval ('document.all.'+myId+'.style');
thestyle.backgroundColor='yellow';
}
}
}
}
function cell(a) {
getid();
e.innerHTML = a.innerHTML ;
var z = document.getElementByTagName("b");
z = documnet.getElementById("b1");
if (z.innerHTML == a.innerHTML)
{
alert("ok");
}
}
function show(div){
div = document.getElementById("div1");
div.style.visibility="visible";
}
</script>
<table border="1"><th onmouseup="show('div1')" id="a1"><b id='b1' style='visibility:hidden'>1</b>?</th></table><br>
<div id="div1" style="visibility:hidden">
<table border=1><th onclick="cell(this, getid())">1</th><th onclick="cell(this, getid())">2</th></table></div>
-
Jan 12, 2007, 00:08 #2
- Join Date
- Dec 2006
- Location
- Prague
- Posts
- 210
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I hope understand what it should do
Code:<script> window.onload=function getid() { obj=document.getElementsByTagName('th'); for(c=0;c<obj.length;c++){ if(obj[c].id!=''){ obj[c].onclick=function(){ document.getElementById(this.id).style.backgroundColor='yellow'; }}}} function cell(a,id){ if (document.getElementById(id).innerHTML == a.innerHTML) {alert("ok");}} function show(div){ document.getElementById(div).style.visibility="visible"; } </script> <table border="1"><th onmouseup="show('div1')" id="a1"><b id='b1' style='visibility:hidden'>1</b>?</th></table><br> <div id="div1" style="visibility:hidden"> <table border=1> <th onclick="cell(this,'b1')">1</th> <th onclick="cell(this,'b1')">2</th> </table> </div>
-
Jan 12, 2007, 00:09 #3
- Join Date
- Sep 2005
- Location
- Sydney, NSW, Australia
- Posts
- 16,875
- Mentioned
- 25 Post(s)
- Tagged
- 1 Thread(s)
var thestyle= eval ('document.all.'+myId+'.style');
should be
var thestyle = document.getElementById(mystyle).style;Stephen J Chapman
javascriptexample.net, Book Reviews, follow me on Twitter
HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
<input name="html5" type="text" required pattern="^$">
-
Jan 12, 2007, 00:14 #4
- Join Date
- Aug 2006
- Posts
- 32
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
thx
this solved my problem. Thank you.
Bookmarks