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
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <script type="text/javascript">
- function granted_pension(str)
- {
- if (str=="")
- {
- document.getElementById("granted_pension").innerHTML="";
- return;
- }
- if (window.XMLHttpRequest)
- {// code for IE7+, Firefox, Chrome, Opera, Safari
- xmlhttp=new XMLHttpRequest();
- }
- else
- {// code for IE6, IE5
- xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
- }
- xmlhttp.onreadystatechange=function()
- {
- if (xmlhttp.readyState==4 && xmlhttp.status==200)
- {
- document.getElementById("granted_pension").innerHTML=xmlhttp.responseText;
- }
- }
- xmlhttp.open("GET","__02.php?granted_pension="+str,true);
- xmlhttp.send();
- }
- </script>
- <script type="text/javascript">
- function salary_book(str)
- {
- if (str=="")
- {
- document.getElementById("salary_book").innerHTML="";
- return;
- }
- if (window.XMLHttpRequest)
- {// code for IE7+, Firefox, Chrome, Opera, Safari
- xmlhttp=new XMLHttpRequest();
- }
- else
- {// code for IE6, IE5
- xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
- }
- xmlhttp.onreadystatechange=function()
- {
- if (xmlhttp.readyState==4 && xmlhttp.status==200)
- {
- document.getElementById("salary_book").innerHTML=xmlhttp.responseText;
- }
- }
- xmlhttp.open("GET","__02.php?salary_book="+str,true);
- xmlhttp.send();
- }
- </script>
- </head>
- <form>
- Pension?
- <select name="pension" onChange="granted_pension(this.value);" style="margin-bottom:3px; width:70px">
- <option value="1">No</option>
- <option value="2">Yes, pension</option>
- </select>
- <div id="granted_pension">
- <div id="calculator-left">Salary book</div>
- <div id="calculator-middle">
- <select name="salary_book_not_submitted" onChange="salary_book(this.value);" style="margin-bottom:3px; width:115px">
- <option value="1">submitted</option>
- <option value="2">not submitted</option>
- </select>
- </div>
- <div id="salary_book">
- show
- </div>
- </div>
- </form>
- </body>
- </html>
Expand|Select|Wrap|Line Numbers
- <?php
- if ($granted_pension==1) {echo '
- Salary book
- <select name="salary_book_not_submitted" onChange="salary_book(this.value);" style="margin-bottom:3px; width:115px">
- <option value="1">submitted</option>
- <option value="2">not submitted</option>
- </select>
- <br>
- show depending on pension option';}
- if ($granted_pension==2) {echo 'hide depending on pension option';}
- if ($salary_book==1) {echo 'show depending on salary book option';}
- if ($salary_book==2) {echo 'hide depending on salary book option';}
- ?>