Thread: Select divs

Page 2 of 2 First 12
  • Jump to page:
    #16
  1. A Not To Shabby Code Smurf
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Aug 2008
    Posts
    1,165
    Rep Power
    184
    Originally Posted by derplumo
    no I mean the parameter for the function, and the class changes in my browser (yes the code). And I think I wasn't clear the other time, I use the function 'inspect element' in Chrome to see the code...

    so I see the code as this:
    Code:
    <div id="nr_div0" class="box selected" onclick="func(0,0);">1</div>
    instead of:
    Code:
    <div id="nr_div0" class="box selected" onclick="func(0,1);">1</div>
    It is set like that, due to the fact; that you had that in your original code; so I incorporated into the code, that I updated for you:
    Code:
    if(selected === 0 && !((' ' + document.getElementById("nr_div"+ nr_div).className + ' ').indexOf(' selected ') > -1)) {
            // select
            num_input = num_input + 1;
            document.getElementById("form").innerHTML="<input type='hidden' id='form"+ nr_div +"' name='nr_div["+ num_input +"]' value='"+ nr_div +"'>";
            a=document.getElementById("nr_div"+ nr_div);
            a.className = a.className + " selected";
            
            document.getElementById("nr_div"+ nr_div).onclick = 'func(nr_div,1);';  
        }

    Comments on this post

    • Winters agrees
  2. #17
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    436
    Rep Power
    8
    it doesn't work... well, it worked in the first place, sorry for the trouble
  4. #18
  5. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    436
    Rep Power
    8
    I got a bug:

    If I have a div1,div2,...,div11 and I select div11 and then div1, and then deselect div1 I get this in the collection:

    Code:
    <input type="hidden" id="collection" name="divs" value="1 div11">
    Is there a way to search and replace the whole word instead of the first in line?
  6. #19
  7. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    436
    Rep Power
    8
    Oh, and I replaced the 'div'+nr with just nr because it is better for processing purposes...
Page 2 of 2 First 12
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo