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

php ajax nested div: no change after ajax call

If I click on "not submitted" at Salary book get text "hide depending on salary book option". Then click on "submitted" at Salary book and get text "show depending on salary book option". That is ok.

Next
Click on "Yes" at Pension. Then click "No" at Pension. So far is ok.

But here is problem. If I click again on "not submitted" at Salary book then no changes.

What do i need to fix (change) in my code?

file __01.php

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  4.  
  5. <script type="text/javascript">
  6. function granted_pension(str)
  7. {
  8. if (str=="")
  9.   {
  10.   document.getElementById("granted_pension").innerHTML="";
  11.   return;
  12.   }
  13. if (window.XMLHttpRequest)
  14.   {// code for IE7+, Firefox, Chrome, Opera, Safari
  15.   xmlhttp=new XMLHttpRequest();
  16.   }
  17. else
  18.   {// code for IE6, IE5
  19.   xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  20.   }
  21. xmlhttp.onreadystatechange=function()
  22.   {
  23.   if (xmlhttp.readyState==4 && xmlhttp.status==200)
  24.     {
  25.     document.getElementById("granted_pension").innerHTML=xmlhttp.responseText;
  26.     }
  27.   }
  28. xmlhttp.open("GET","__02.php?granted_pension="+str,true);
  29. xmlhttp.send();
  30. }
  31. </script>
  32.  
  33. <script type="text/javascript">
  34. function salary_book(str)
  35. {
  36. if (str=="")
  37.   {
  38.   document.getElementById("salary_book").innerHTML="";
  39.   return;
  40.   }
  41. if (window.XMLHttpRequest)
  42.   {// code for IE7+, Firefox, Chrome, Opera, Safari
  43.   xmlhttp=new XMLHttpRequest();
  44.   }
  45. else
  46.   {// code for IE6, IE5
  47.   xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  48.   }
  49. xmlhttp.onreadystatechange=function()
  50.   {
  51.   if (xmlhttp.readyState==4 && xmlhttp.status==200)
  52.     {
  53.     document.getElementById("salary_book").innerHTML=xmlhttp.responseText;
  54.     }
  55.   }
  56. xmlhttp.open("GET","__02.php?salary_book="+str,true);
  57. xmlhttp.send();
  58. }
  59. </script>
  60.  
  61.  
  62. </head>
  63.  
  64. <form>
  65.  
  66. Pension?
  67. <select name="pension" onChange="granted_pension(this.value);" style="margin-bottom:3px; width:70px">
  68. <option value="1">No</option>
  69. <option value="2">Yes, pension</option>
  70. </select>     
  71.  
  72.  
  73. <div id="granted_pension">
  74.  
  75. <div id="calculator-left">Salary book</div>
  76. <div id="calculator-middle">
  77. <select name="salary_book_not_submitted" onChange="salary_book(this.value);" style="margin-bottom:3px; width:115px">
  78. <option value="1">submitted</option>
  79. <option value="2">not submitted</option>
  80. </select>     
  81. </div>
  82.  
  83.  
  84. <div id="salary_book">
  85.  
  86.  
  87. show
  88.  
  89. </div>
  90. </div>
  91.  
  92.  
  93.  
  94. </form>
  95.  
  96.  
  97. </body>
  98. </html>
  99.  
  100.  
file __02.php

Expand|Select|Wrap|Line Numbers
  1.  
  2. <?php
  3.  
  4. if ($granted_pension==1) {echo '
  5. Salary book
  6. <select name="salary_book_not_submitted" onChange="salary_book(this.value);" style="margin-bottom:3px; width:115px">
  7. <option value="1">submitted</option>
  8. <option value="2">not submitted</option>
  9. </select>     
  10. <br>
  11. show depending on pension option';}
  12. if ($granted_pension==2) {echo 'hide depending on pension option';}
  13.  
  14.  
  15. if ($salary_book==1) {echo 'show depending on salary book option';}
  16. if ($salary_book==2) {echo 'hide depending on salary book option';}
  17.  
  18.  
  19.  
  20. ?>
  21.  
Dec 28 '12 #1
1 2349
Sorry, get solution by myself. May be for someone else would be useful.
file __02.php

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. if ($granted_pension==1) {echo '
  4. Salary book (pension variable)
  5. <select name="salary_book_not_submitted" onChange="salary_book(this.value);" style="margin-bottom:3px; width:115px">
  6. <option value="1">submitted</option>
  7. <option value="2">not submitted</option>
  8. </select>     
  9. <br>
  10. <div id="salary_book">
  11. show depending on pension option
  12. </div>
  13. ';}
  14. if ($granted_pension==2) {echo '<br><br>hide depending on pension option';}
  15.  
  16.  
  17.  
  18.  
  19. if ($salary_book==1) {echo '<br><br>show depending on salary book option';}
  20. if ($salary_book==2) {echo '<br><br>hide depending on salary book option';}
  21.  
  22.  
  23.  
  24. ?>
  25.  
Dec 28 '12 #2

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

Similar topics

1
by: David Shorthouse | last post by:
Hello folks, I just started thinking about a db-driven, 3-tier nested option menu in AJAX instead of the typical onchange --> post. I seem to have something working, but the resultant formatting...
31
by: Tony | last post by:
I just noticed that prototype.js is one of the files in the Ajax.NET distribution - I'm pretty concerned about this. Does anyone know if this is the same "prototype.js" that is not well-liked...
0
by: Rich Bamford | last post by:
Has anyone got any experience of nesting ajax modal popups using modalpopupextender? I.e. a popup that has a button to show a further popup. I'm trying to convert a non-ajax page where a 'popup'...
1
by: geevaa | last post by:
http://www.phpbuilder.com/columns/kassemi20050606.php3 XMLHttpRequest and AJAX for PHP programmers James Kassemi Introduction: Although the concept isn't entirely new, XMLHttpRequest...
8
by: =?Utf-8?B?SmFrb2IgTGl0aG5lcg==?= | last post by:
I am new to AJAX. I am applying AJAX to a current web solution to get the "instant behaviour". On my main page I have two sets of criteria: Specific and Wide. Each set is placed in a View...
1
by: steve.chambers | last post by:
Is it possible to do this? Does AJAX allow one call to be made within another?? So far I'm having problems. Below I've tried to simplify my code into its basic elements - the problem I'm getting is...
3
by: dhsieh | last post by:
I am trying out nested AJAX calls for the first time, but I seem to have hit a snag. The code snippet is the outer AJAX call and a function, it gathers information about a company. As we get towards...
0
by: Marc | last post by:
"jacoberg2" <jacoberg2@hotmail.comwrote in message news:cdcbd57a-8736-464e-9c57-defedcd3c7ff@l42g2000hsc.googlegroups.com... Never heard of this before....! Are you sure it's not reloading the...
8
by: Tomasz J | last post by:
Hello developers, After migrating my web project application (using the old model) to .Net Framework 3.5 and Ajax Control Toolkit release 20820 the Accordion control no longer works correctly....
3
by: somtabu | last post by:
Hello... I want to make nested accordian with the help of AJAX ACCORDIAN control. Please help...... Thank you.
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
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,...
1
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

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.