473,395 Members | 1,791 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,395 software developers and data experts.

Html form not sending input elements loaded using Ajax

I've got a problem, I'm working with Ajax in a web with a form with a list of checkbox added to the form via an Ajax.Updater method. These added checkboxs are not been sended by the form if I use Firefox or Safari.

My source code is something like that:
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript" src="http://www.my_web_page.com//js/prototype-1.4.0.js"></script>
  2. <script>
  3. function showMoreOptions( url, pars, div_id ){    
  4.     if (document.getElementById(div_id).style.display=='block'){
  5.         document.getElementById(div_id).style.display='none';
  6.     } else {
  7.         document.getElementById(div_id).style.display='block';
  8.         var myAjax = new Ajax.Updater( {success: div_id}, url, { method: 'post', parameters: pars });
  9.     }
  10. }
  11. </script>
  12. <form name="form_name" method="post" action="script.cgi">
  13. <table border="0" cellspacing="0" cellpadding="1" align="center">
  14. <tr><td><input type="checkbox" name="1" value="1"></td><td width="100%">Option 1</td></tr>
  15. <tr><td><input type="checkbox" name="2" value="2"></td><td width="100%">Option 2</td></tr>
  16. </table>
  17. <table width="100%" cellspacing="0" cellpadding="0" border="0">
  18. <tr><td><a href="javascript:showMoreOptions('http://www.my_web_page.com', 'do=more_options', 'more');">More options</a></td></tr>
  19. <tr><td><div id="more" style="position:relative;display:none;"></div></td></tr>
  20. </table>
  21. </form>
When the user 'clicks' on 'more options', the javascript function does make a call to a cgi script using Ajax. This call returns a piece of code 'html' like that:

Expand|Select|Wrap|Line Numbers
  1. <table border="0" cellspacing="0" cellpadding="1" align="center">
  2. <tr><td><input type="checkbox" name="3" value="3"></td><td width="100%">Option 3</td></tr>
  3. </table>
That code is placed into the div called 'more' using Ajax.Updater method.
Everything works ok in explorer, but if the user works with firefox or safari the checkbox returned via ajax (the one in the div tag) is not sended to the cgi script. Is like if the checkbox wasn't into the form. Of course if I use the 'view source code' option in firefox and safari the div is empty. And if I make a list of the elements in the form using form.elements property using javascript the checkbox doesn't show up.

Someone knows why does it works with explorer and why it doesn't works using the other navigators?
Can you give me a solution?
Nov 22 '06 #1
3 2949
I have an ajax updater method that updates a div element with html and input elements. All this
code is inside a form. With IE if I submit the form I can collect this input elments, but with
Firefox I can't, because this elements (the ones inside the div) are not sended to my cgi.

I don't know how to deal with that problem. Can someone help me please?
Nov 24 '06 #2
AricC
1,892 Expert 1GB
Post your code.
Nov 25 '06 #3
Here is my code:

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript" src="http://www.my_web_page.com//js/prototype-1.4.0.js"></script>
  2. <script>
  3. function showMoreOptions( url, pars, div_id ){    
  4.     if (document.getElementById(div_id).style.display=='b  lock'){
  5.         document.getElementById(div_id).style.display='non  e';
  6.     } else {
  7.         document.getElementById(div_id).style.display='blo  ck';
  8.         var myAjax = new Ajax.Updater( {success: div_id}, url, { method: 'post', parameters: pars });
  9.     }
  10. }
  11. </script>
  12. <form name="form_name" method="post" action="script.cgi">
  13. <table border="0" cellspacing="0" cellpadding="1" align="center">
  14. <tr><td><input type="checkbox" name="1" value="1"></td><td width="100%">Option 1</td></tr>
  15. <tr><td><input type="checkbox" name="2" value="2"></td><td width="100%">Option 2</td></tr>
  16. </table>
  17. <table width="100%" cellspacing="0" cellpadding="0" border="0">
  18. <tr><td><a href="javascript:showMoreOptions('http://www.my_web_page.com', 'do=more_options', 'more');">More options</a></td></tr>
  19. <tr><td><div id="more" style="position:relative;display:none;"></div></td></tr>
  20. </table>
  21. </form>
When the user 'clicks' on 'more options', the javascript function does make a call to a cgi script using Ajax. This call returns a piece of code 'html' like that:

Expand|Select|Wrap|Line Numbers
  1. <table border="0" cellspacing="0" cellpadding="1" align="center">
  2. <tr><td><input type="checkbox" name="3" value="3"></td><td width="100%">Option 3</td></tr>
  3. </table>
That code is placed into the div called 'more' using Ajax.Updater method.
Everything works ok in explorer, but if the user works with firefox or safari the checkbox returned via ajax (the one in the div tag) is not sended to the cgi script. Is like if the checkbox wasn't into the form. Of course if I use the 'view source code' option in firefox and safari the div is empty. And if I make a list of the elements in the form using form.elements property using javascript the checkbox doesn't show up.

Can you give me a solution?
Nov 28 '06 #4

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

Similar topics

1
by: Yaron C. | last post by:
Hello, I would like to ask for your help. I am trying to create a page with table of many form elements. The size of the table is 84x10 (84 rows, 10 columns) and each cell contains 1 form...
3
by: Kathy | last post by:
Can someone help me with the code to take the data in four fields on an HTML form and add it to a table in a database on an intranet. Thanks to all who help! Kathy
3
by: lcjohnso | last post by:
Hi all, Does anyone know if there is an easy way to create the html representation of an HTMLElement object in javascript? I'm attempting to update the innerHTML property of a div element to...
2
by: pamelafluente | last post by:
Hi dears, I have a plain HTML page. I want to render it a little interactive. I was thinking to add to it 1 script and events to the elements I want to make interactive. Then, I need to...
2
by: sarafat | last post by:
greetings people I am new to Ajax and javascript, yet i have little time to learn it all. Question is: i am using javascript to create my DOM Table and AJAX that returns a DataSet to my...
8
by: VUNETdotUS | last post by:
My goal is to upload files without submitting the form. I am not looking for the code here but rather a concept. I did a little research and discovered that I can submit a form to an invisible...
10
by: Kelly | last post by:
Can anyone tell me what I'm doing wrong here? ================================== <html> <head> <title>Test Form</title> <script language="JavaScript" type="text/javascript"> </head>
3
by: Sunny | last post by:
Hi, Can someone tell me, How to load the Body Html from a text file that contains javascript. to Manage my files I am creating an Index Page. <html> <head> <meta http-equiv="content-type"...
2
by: Mike | last post by:
Hello, I am trying to pass a js array ,Round1, to a form and send it. I can get it to work with serialized values but I want to send the data as an array. The arrays are filled with data. I am...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.