Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Checkboxes


  • Please log in to reply
20 replies to this topic

#13 BlaineSch

BlaineSch

    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1559 posts

Posted 07 November 2009 - 01:56 PM

Right, but if you look at the code, the "abc" "def" "ghi" comes together since it appends the checkboxes to the end, if you disable javascript they are not like that.
  • 0

#14 Vswe

Vswe

    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1989 posts
  • Programming Language:Java, C#, PHP, Python, JavaScript, PL/SQL, Visual Basic .NET, Lua, ActionScript

Posted 07 November 2009 - 02:09 PM

I've been trying for a while and I've thought I understood what everything did but apparently not, why do you create that "el" thing?
  • 0

#15 BlaineSch

BlaineSch

    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1559 posts

Posted 07 November 2009 - 02:20 PM

I created el, assigned it's inner HTML the data variable which you cannot just alert out, but if you assign it that way you can then alert the innerhtml of el, or assign it in my case, I just used that one guy's code and modified it.
  • 0

#16 Vswe

Vswe

    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1989 posts
  • Programming Language:Java, C#, PHP, Python, JavaScript, PL/SQL, Visual Basic .NET, Lua, ActionScript

Posted 07 November 2009 - 02:47 PM

Everything is the appendChild's fault, with outerHTML it would be easy. I'm giving up for tonight. Good Luck. I'll try to figure out something.
  • 0

#17 BlaineSch

BlaineSch

    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1559 posts

Posted 07 November 2009 - 02:48 PM

But outerHTML is not supported in Firefox lol
  • 0

#18 Vswe

Vswe

    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1989 posts
  • Programming Language:Java, C#, PHP, Python, JavaScript, PL/SQL, Visual Basic .NET, Lua, ActionScript

Posted 07 November 2009 - 02:50 PM

I know and that's the problem. The solution you found puts the element you got the outerHTML from at the end since you append it to the parent. I have no ideas left.
  • 0

#19 BlaineSch

BlaineSch

    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1559 posts

Posted 07 November 2009 - 03:13 PM

Okay, so far what I got now.

It goes through and creates all the id's goes back through and updates them.

Update just makes a div, appends the current node, and tries to replace the original node with the new div node.

This gives me an error.. saying node not found?

<style>
div.one1 {
background: blue;
padding:3px;
}
div.one2 {
background: red;
padding:3px;
}
div.one3 {
background: green;
padding:3px;
}
</style>
<table>
<tr>
<td>
1)
<input type="checkbox" name="helloworld1">
2)
<input type="checkbox" name="helloworld2">
3)
<input type="checkbox" name="helloworld3">
</td>
</tr>
</table>
<script>
var bs = 0;
var data = document.getElementsByTagName("input");
for (var i = 0; i < data.length; i++) {
data[i].id="bsBetavs10"+bs; //gets element
bs++;
}
for(i = 0;i<bs;i++) {
update("bsBetavs10"+i);
}
function update(id) {
var data = document.getElementById(id);
var parent = data.parentNode;
var newdiv = document.createElement('div');
newdiv.className = "one";
newdiv.appendChild(data);
parent.replaceChild(newdiv, data);
}
</script>


What's up with the HTML highlighting? lol
  • 0

#20 BlaineSch

BlaineSch

    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1559 posts

Posted 07 November 2009 - 03:55 PM

Screw this. Regex FTW!

<style>
div.one1 {
background: blue;
padding:3px;
}
div.one2 {
background: red;
padding:3px;
}
div.one3 {
background: green;
padding:3px;
}
</style>
<table>
<tr>
<td class="findme">
1)
<input id="one" type="checkbox" name="helloworld1"><input id="one" type="checkbox" name="helloworld4">
2)
<input id="two" type="checkbox" name="helloworld2">
3)
<input id="three" type="checkbox" name="helloworld3">
</td>
</tr>
</table>
<script>
var data = document.getElementsByTagName('body')[0];
data.innerHTML = data.innerHTML.replace(/<input([^>]*)>/g, "<div class='one1'><input $1></div>");
</script>


Works perfect.
  • 0

#21 Vswe

Vswe

    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1989 posts
  • Programming Language:Java, C#, PHP, Python, JavaScript, PL/SQL, Visual Basic .NET, Lua, ActionScript

Posted 08 November 2009 - 01:36 AM

Nice that it works, now I don't need to be so frustrated anymore :P
  • 0




Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download