473,378 Members | 1,330 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Checkboxes created using Javascript DOM not available in $_POST

69
Hi,

I have a Javascript function that creates a number of checkboxes dynamically using document.createElement. The checkboxes are created fine but even when they are checked they don't appear in $_POST in Internet Explorer. The same code works fine in Firefox and I can get the details of the checkboxes that are checked. Does anyone know of any problems with checkboxes in IE?

Thanks,

Sean
Oct 13 '07 #1
2 1781
pbmods
5,821 Expert 4TB
Heya, Sean.

Make sure you're attaching the checkboxes to an element inside the form.

For example:
Expand|Select|Wrap|Line Numbers
  1. function addCheck()
  2. {
  3.     var newCheck = document.createElement('input');
  4.     .
  5.     .
  6.     .
  7.     document.getElementById('insertHere').appendChild(newCheck);
  8. }
  9.  
If insertHere is here:
Expand|Select|Wrap|Line Numbers
  1. <form ... >
  2.     .
  3.     .
  4.     .
  5. </form>
  6.  
  7. <div id="insertHere"></div>
  8.  
then the new checkboxes will not be submitted with the form. But if insertHere is here:
Expand|Select|Wrap|Line Numbers
  1. <form ... >
  2.     .
  3.     .
  4.     .
  5.     <div id="insertHere"></div>
  6. </form>
  7.  
The new checkboxes will be submitted.
Oct 13 '07 #2
Sebarry
69
Yep thought of that but it's definately not that. I don't understand why it works in Firefox but not IE.

Expand|Select|Wrap|Line Numbers
  1. var cb = document.createElement( "input" );
  2. cb.type = "checkbox";
  3. cb.name = htmlIdName;
  4. cb.id = htmlIdName;
  5. cb.value = xmlOptions[i].getElementsByTagName('id')[0].firstChild.data;
  6. subDiv.appendChild( checkBoxName );
  7. subDiv.appendChild( cb );
  8. subDiv.innerHTML += "<br />";
  9.  
Like I said when I put in an alert I can print out the value and checked status of my checkboxes but even when they're checked they don't appear in $_POST.

It's strange and frustrating.

Heya, Sean.

Make sure you're attaching the checkboxes to an element inside the form.

For example:
Expand|Select|Wrap|Line Numbers
  1. function addCheck()
  2. {
  3.     var newCheck = document.createElement('input');
  4.     .
  5.     .
  6.     .
  7.     document.getElementById('insertHere').appendChild(newCheck);
  8. }
  9.  
If insertHere is here:
Expand|Select|Wrap|Line Numbers
  1. <form ... >
  2.     .
  3.     .
  4.     .
  5. </form>
  6.  
  7. <div id="insertHere"></div>
  8.  
then the new checkboxes will not be submitted with the form. But if insertHere is here:
Expand|Select|Wrap|Line Numbers
  1. <form ... >
  2.     .
  3.     .
  4.     .
  5.     <div id="insertHere"></div>
  6. </form>
  7.  
The new checkboxes will be submitted.
Oct 14 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Pete | last post by:
There is a Summary/Example further down... On page one of my site I have a form with some checkboxes and detailed descriptions. When the form is submitted (to page two), the values of the...
4
by: Ken | last post by:
I have a two checkboxes in HTML: <input TYPE="checkbox" NAME="cc" VALUE="true"></td><td><b>Credit Card</b></td></tr> <input TYPE="checkbox" NAME="cash" VALUE="true"></td><td><b>Company...
9
by: sergio | last post by:
Hi all, I have created the following script that will show/hide a menu based on checkboxes. It works fine in Opera but not on IE6! Does anybody knows a workaround this problem? Thanks for your...
15
by: Sonnich | last post by:
Hi all! I have a file where I'd have to submit buttons, and I need to differ between those. Step #1 - open html win with default selection Step #2 - user may select some criteries for the...
2
by: GustavoBrust | last post by:
Hello everyone. I'm having a problem with a search I want to make. It's like this: The user can choose about 15 checkboxes to be his search pattern. According to the combination of...
4
by: jeet | last post by:
Plz help me.Problem is that On the first page I display all other user with checkbox and give user option to select only two user which he wants to send message. Tell me please how I'll get those...
9
by: Sebarry | last post by:
Hi, I've put together a little test page to create checkboxes each time a button is clicked. The check button is created and should be appended to the form, but when the post is submitted the...
2
by: phpachu | last post by:
Hi, I hav created a group of textboxes using a loop and its names are unique and names are assigned using variable ( like <input type=text name=$name1>). Then How can i retrieve the values in...
6
by: ahilar12 | last post by:
<html> <head> <script type="text/javascript"> function SetAllCheckBoxes(FormName, FieldName, CheckValue) { if(!document.forms) return; var objCheckBoxes = document.forms.elements;...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.