471,305 Members | 1,278 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Javascript & Browser compatiblity?

1
I'm builiding an online insurance application, where people input thier data, and it gives them rates, then lets them apply. I was wondering if someone could take a look and maybe tell me what the issue is?

Here is the url: http://67.62.217.33/test5

You will need to supply a valid zip, as it does a check for areas the insurance is available. You can use 23834

The issue I'm having is on the the next page there, intro-page2.asp, if you fill in your information or select add a child and then submit that, it takes you to the page with your quotes. No problem there. The problem is that if you use either the back button I have on the page or the browsers in IE, nothing is retained and the dropdowns disappear. But in FF, everything is fine.

Here is the JS I'm using to create the dropdowns:
Expand|Select|Wrap|Line Numbers
  1. function addEvent()
  2. {
  3. var ni = document.getElementById('myDiv');
  4. var numi = document.getElementById('theValue');
  5. //var num = (document.getElementById("theValue").value - 1)+ 2;
  6. var num = (document.getElementById("theValue").value -1)+ 2;
  7. numi.value = num;
  8. var divIdName = "my"+num+"Div";
  9. var newdiv = document.createElement('div');
  10. newdiv.setAttribute("id",divIdName);
  11. newdiv.innerHTML = 
  12. "<tr align=\"right\">"+
  13. "<td width=\"66\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Child&nbsp;&nbsp;&nbsp;</td>"+
  14. "<td width=\"78\">"+
  15. "<select name=\"child"+num+"_gender\" id=\"child"+num+"_gender\">"+
  16. "<option value=\"\" selected>- -<\/option>"+
  17. "<option value=\"Male\">Male<\/option>"+
  18. "<option value=\"Female\">Female<\/option>"+
  19. "<\/select>"+
  20. "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/td>"+
  21. "<td width=\"169\">"+
  22. "<input name=\"child"+num+"_dob_mm\" type=\"text\" id=\"child"+num+"_dob_mm\" style=\"width: 30px;\" />"+
  23. "&nbsp;/ <input name=\"child"+num+"_dob_dd\" type=\"text\" id=\"child"+num+"_dob_dd\" style=\"width: 30px;\" />"+
  24. "&nbsp;/ <input name=\"child"+num+"_dob_yyyy\" type=\"text\" id=\"child"+num+"_dob_yyyy\" style=\"width: 40px;\" />"+
  25. "<\/td>"+
  26. "<td width=\"59\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input name=\"child"+num+"_tobacco\" type=\"checkbox\" id=\"child"+num+"_tobacco\" /></td>"+
  27. "<td width=\"74\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input name=\"child"+num+"_college\" type=\"checkbox\" id=\"child"+num+"_college\" /></td>"+
  28. "<td width=\"69\" >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input name=\"child"+num+"_hippa\" type=\"checkbox\" id=\"child"+num+"_hippa\" /></td>"+
  29. "<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"javascript:;\" onclick=\"removeEvent(\'"+divIdName+"\')\">Remove<\/a></td>"+
  30. "<\/tr>";
  31. ni.appendChild(newdiv);
  32.  
  33. }
  34.  
  35.  
  36. function removeEvent(divNum)
  37. {
  38. var d = document.getElementById('myDiv');
  39. var olddiv = document.getElementById(divNum);
  40. d.removeChild(olddiv);
  41. }
  42.  
I also included the following snippet of ASP code to the top of my page:
Expand|Select|Wrap|Line Numbers
  1. <% Response.CacheControl = "no-cache" %>
  2. <% Response.AddHeader "Pragma", "no-cache" %>
  3. <% Response.Expires = -1 %>
  4.  
The reason I added this was becasue in IE, when you page back the dropdowns disappear and if you try to re-add them and re-post the page, the values corresponding to the "Add Child" dropdown don't post. However in FF, everything works fine. So that little bit of ASP was the only way I could get the values to refresh & work.

I'm in desperate need of help to figure out the problem here, cause I've tried everything I can think of and I can't get it to work properly in IE.

Thanks in advance.
Oct 3 '06 #1
1 1194
acoder
16,027 Expert Mod 8TB
Elements added dynamically won't remain once you leave the page, so you need to add them again onload.
May 20 '08 #2

Post your reply

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

Similar topics

3 posts views Thread by Ivan P | last post: by
26 posts views Thread by Laurent Bugnion [MVP] | last post: by
3 posts views Thread by DVir | last post: by
reply views Thread by rosydwin | last post: by

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.