Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript 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 May 22nd, 2006, 10:54 AM
Registered User
 
Join Date: May 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Get the descriptors of JS-created checkboxes

Hi all!

I need by JS add several objects <input > of type checkbox. And names and quality of these objects may be
different in different cases After that I need to verify which of created objects are checked.
The problem is that submiting the form I do not have any of new created checkboxs. Moreover, if after cteation
of these checkbox I need to get desriptors of these checkbox-(I need it)
I run a circle like:
  for (i=0; i< theForm.elements.length; i++) {
    alert( theForm.elements[i].name );
but I do not see names or id's of these checkboxes!

I do it so:
  var NewRow=document.getElementById("radio_table").inse rtRow(-1); // radio_table - table with checkboxes

  var CheckBoxCell= NewRow.insertCell(-1); // Add new row
  var ObjName= "templateRadio_tmplRootService"; // the njame of a new checkbox
  var isChecked = ' "checked" '; // checkbox id checked
  CheckBoxCell.innerHTML= "<INPUT TYPE=checkbox id=\""+ObjName+"\" name=\""+ObjName+"\" VALUE=\"Y\" "+isChecked+" > ";//+cn+" ("+objclass+","+objcategory+")";
  CheckBoxCell.form= document.TemplateDbEditor; // I tried to set the property form of created cell?
  alert("CheckBoxCell.innerHTML:::"+CheckBoxCell.inn erHTML); // look my html-code:
<input id="templateRadio_tmplRootService" name="templateRadio_tmplRootService" value="Y" checked= "checked" type="checkbox">

How may I do this?
  Thanks in advance,
       Nilov Serge.

&nbsp;&nbsp;Thanks in advance,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Nilov Serge.
 
Old May 27th, 2006, 12:04 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

Hi NilovSerge!!
plz try this code
<script>

function createRow()
    {var NewRow=document.getElementById("radio_table").inse rtRow(-1); // radio_table - table with checkboxes
    var CheckBoxCell= NewRow.insertCell(-1); // Add new row

obj=document.createElement("input")
obj.type="checkbox"
obj.id="myid"
obj.name="myid"
  CheckBoxCell.appendChild(obj)
 }

function getFormName()
{
for (i=0; i< document.myform.elements.length; i++)
    alert( document.myform.elements[i].name );

}
</script>
<form name="myform">
<input type=button name=dsaf onclick="getFormName()" value=formnameval>
<table id="radio_table">
<tr><td>Hkk</td></tr>
</table>
<input type=button name=df value="createChekbox" onclick="createRow()">
<input id="templateRadio_tmplRootService" name="templateRadio_tmplRootService" value="Y" checked= "checked" type="checkbox">
</form>

Hope this will help you



Cheers :)

vinod





Similar Threads
Thread Thread Starter Forum Replies Last Post
To include a js file into another js file jdang67 Javascript 4 February 28th, 2008 03:32 AM
checkboxes check is it possible using js blueguy Javascript 1 October 26th, 2004 02:35 AM





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