using javascript loops to create multiple checkboxes

using javascript loops to create multiple checkboxes

Page 1 of 1

3 Replies - 24467 Views - Last Post: 18 August 2006 - 02:04 PM

#1 shaunjon  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 1
  • Joined: 18-August 06

using javascript loops to create multiple checkboxes

Posted 18 August 2006 - 01:52 AM

hi there, please help me. i want create multiple checkboxes using javascript and assign loop counter to the checkbox values.
please advise.
thanx alot.
Is This A Good Question/Topic? 1

Replies To: using javascript loops to create multiple checkboxes

#2 snoj  Icon User is offline

  • Married Life
  • member icon

Reputation: 84
  • View blog
  • Posts: 3,564
  • Joined: 31-March 03

Re: using javascript loops to create multiple checkboxes

Posted 18 August 2006 - 07:33 AM

<input type="checkbox" name="acheckbox[n]" value="whatever" />

This basically makes acheckbox an array. n is the index/key value. It can be left blank and the value will auto increment.
Was This Post Helpful? 0
  • +
  • -

#3 quim  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 18
  • View blog
  • Posts: 182
  • Joined: 11-December 05

Re: using javascript loops to create multiple checkboxes

Posted 18 August 2006 - 09:49 AM

View Postshaunjon, on 18 Aug, 2006 - 01:52 AM, said:

hi there, please help me. i want create multiple checkboxes using javascript and assign loop counter to the checkbox values.
please advise.
thanx alot.

you may want something like this:
<script>
var count

var check_value = new Array()
check_value[0] = "value1"
check_value[1] = "value2"
check_value[2] = "value3"
check_value[3] = "value4"

for(count in check_value)
{

var checkbox = "<input type='checkbox' value='"+check_value[count]+"' />"
document.write(checkbox + check_value[count] + "<br/>")

}
</script>




Was This Post Helpful? 0
  • +
  • -

#4 snoj  Icon User is offline

  • Married Life
  • member icon

Reputation: 84
  • View blog
  • Posts: 3,564
  • Joined: 31-March 03

Re: using javascript loops to create multiple checkboxes

Posted 18 August 2006 - 02:04 PM

Teh Rulez:

Quote

Post the code you have so far using the [code] tags. We can't help you if you don't post your code. We will not do your homework for you. You MUST show some effort.

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1