Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Ajax
|
Ajax the combination of XHTML, CSS, DOM, XML, XSLT, XMLHttpRequest, and JavaScript
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Ajax section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 2nd, 2009, 12:55 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 198
Thanks: 2
Thanked 0 Times in 0 Posts
Send a message via MSN to itHighway
Default Ajax - Creating checkboxes

Using Ajax below is how we create HTML SELECT box.
Quote:

if (xmlHttp.readyState == 4)
{
if (xmlHttp.status == 200)
{
var result = xmlHttp.responseText;
var values = result.split("|");

for (var i=0; i<values.length; i++)
{
var newOption = document.createElement('option');
newOption.value = values[i];
newOption.text = values[i]; // Mozilla specific
document.myForm.lngCityId.appendChild(newOption);
}

document.myForm.lngCityId.focus();

}
}
What is the procedure of creating CHECK BOXES?? I want to show City name along with checkbox.
 
Old April 2nd, 2009, 04:06 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

I don't see that this is an Ajax question at all but on most modern browsers (there used to be a problem with IE over this) you can do something like:
Code:
for (var i=0; i<values.length; i++)
{
  var chk = document.createElement("input");
  chk.type = "checkbox";
  var id = "chkCity" + i;
  chk.id = id;
  chk.name = id;
  document.myForm.lngCityId.appendChild(chk);
  var lbl = document.createElement("label");
  label.innerHTML = values[i];
  label.htmlFor = id;
  document.myForm.lngCityId.appendChild(lbl);
}
You may also need to create and append a br element depending on the layout you want.
__________________
Joe
http://joe.fawcett.name/





Similar Threads
Thread Thread Starter Forum Replies Last Post
Recommend an AJAX IDE - JoyiStar AJAX WebShop. kingstar Ajax 4 December 15th, 2006 05:12 AM
creating checkboxes at runtime abhishekdubey_997 ASP.NET 1.0 and 1.1 Basics 14 November 24th, 2006 01:56 AM
New Ajax article: Creating an Ajax Search W jminatel BOOK: Professional JavaScript for Web Developers ISBN: 978-0-7645-7908-0 1 May 11th, 2006 03:45 PM
new Ajax article: Creating an Ajax Search Widget jminatel Ajax 0 May 11th, 2006 02:50 PM
New Ajax Article: Ajax Submission Throttling jminatel Ajax 0 April 11th, 2006 08:00 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.