creating a sticky form compatible with onChange

Reply

Join Date: Oct 2006
Posts: 82
Reputation: assgar is an unknown quantity at this point 
Solved Threads: 0
assgar assgar is offline Offline
Junior Poster in Training

creating a sticky form compatible with onChange

 
0
  #1
Mar 26th, 2008
Hi

I was using PHP sessions to create a sticky form but a
button was needed to reload the page.

I am new to Java and I have decided to do away with the button.
Using onChange="javascript:OnChange(this) to cause the
page to reload once a selection is made from a dynamic dropdown works.

The problem is the input box and other dropdown on the same page lose
their information. How can I create a sticky form that is
compatible with onChange?

Thanks

  1.  
  2. <?
  3. include("../priority_low_to_high_in.php");//proiority drop down
  4. ?>
  5.  
  6.  
  7. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  8. "http://www.w3.org/TR/html4/loose.dtd">
  9. <html>
  10. <head>
  11. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  12. <title>Calendar</title>
  13. <link href="../config.css" rel="stylesheet" type="text/css"/>
  14. <script language="JavaScript" type="text/JavaScript">
  15. <!--
  16. function OnChange(dropdown)
  17. {
  18. window.location.href="http://localhost/search_form.php?pro_id=" +
  19. dropdown.options[dropdown.selectedIndex].value;
  20. }
  21.  
  22.  
  23. function MM_reloadPage(init)
  24. { //reloads the window if Nav4 resized
  25. if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
  26. document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  27. else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
  28. }
  29. MM_reloadPage(true);
  30. //-->
  31. </script>
  32.  
  33. <style type="text/css">
  34. <!--
  35.  
  36. -->
  37. </style>
  38. </head>
  39.  
  40. <!-----------------------form processor---------------------------->
  41. <form action="../search_process.php" name="calendar" method="post">
  42.  
  43. <tr>
  44. <td>
  45. <select name= "provider_id" onChange="javascript:OnChange(this);">
  46. <?
  47. //display lastname and first name
  48. provider_first_last_name_display($name, $name_val, $db_id);
  49. ?>
  50. </select>
  51. </td>
  52. </tr>
  53.  
  54. <tr>
  55. <td>
  56. <!---reason input---->
  57. <input type="text" name="reason" size="30" maxlength="60" value ="<?php echo $reason; ?>">
  58. </td>
  59. </tr>
  60.  
  61. <tr>
  62. <td>
  63. <!--priority dropdown-->
  64. <select name="priority">
  65. <?php
  66. $priority_name = get_b_priority_name($b_priority_n);
  67. $priority_code = get_b_priority_code($b_priority_c);
  68. for($n = 1; $n<= 6; $n++)
  69. {
  70. $sname = $priority_name[$n];
  71. $scode = $priority_code[$n];
  72. echo "<option value = '$scode'";
  73. if ($scode == " ")
  74. {
  75. echo "selected";
  76. }
  77. echo "> $sname";
  78. }
  79. ?>
  80. </select>
  81. </td>
  82. </tr>
  83. </body>
  84. </from>
  85. </html>
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,761
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 332
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: creating a sticky form compatible with onChange

 
0
  #2
Mar 26th, 2008
You can do this.
<input type="text" name="firstname" value="<?php echo $_POST['firstname']; >?">
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 82
Reputation: assgar is an unknown quantity at this point 
Solved Threads: 0
assgar assgar is offline Offline
Junior Poster in Training

Re: creating a sticky form compatible with onChange

 
0
  #3
Mar 26th, 2008
Hi

Thanks for responding.

I will try the version of code you seggested

I did tried this before posting but the data was still lost:

  1. <?
  2. <input type="text" name="reason" size="30" maxlength="60"
  3. value="<?php if(! empty($_POST['reason'])){echo $_POST['reason'];} else
  4. {echo"$reason";}?>">
  5.  
  6. ?>
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,761
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 332
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: creating a sticky form compatible with onChange

 
0
  #4
Mar 26th, 2008
It will work. Why are you checking if $_POST['reason'] is empty ? What is stored in $reason ?
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 82
Reputation: assgar is an unknown quantity at this point 
Solved Threads: 0
assgar assgar is offline Offline
Junior Poster in Training

Re: creating a sticky form compatible with onChange

 
0
  #5
Mar 27th, 2008
It could be my work, but I find isset() not always as reliable as empty().

I check form field because it is preloaded with information using $reason array.
Last edited by assgar; Mar 27th, 2008 at 10:44 pm.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,761
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 332
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: creating a sticky form compatible with onChange

 
0
  #6
Mar 28th, 2008
Then your code seems ok ! I dont see any problem..
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 82
Reputation: assgar is an unknown quantity at this point 
Solved Threads: 0
assgar assgar is offline Offline
Junior Poster in Training

Re: creating a sticky form compatible with onChange

 
0
  #7
May 31st, 2008
Thanks for the suggestions I will try it.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the PHP Forum


Views: 2554 | Replies: 6
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC