SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    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;
    document.getElementById(myId);
     var 
    thestyle= eval ('document.all.'+myId+'.style');
     
    thestyle.backgroundColor='yellow';
        }
       }
      }
     }
    function 
    cell(a) {
    getid();
    e.innerHTML a.innerHTML ;
    var 
    document.getElementByTagName("b");
        
    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> 

  2. #2
    SitePoint Addict Mirek Komárek's Avatar
    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>

  3. #3
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,786
    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="^$">

  4. #4
    SitePoint Enthusiast
    Join Date
    Aug 2006
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    thx

    this solved my problem. Thank you.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •