943,822 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 3365
  • PHP RSS
Mar 26th, 2008
0

creating a sticky form compatible with onChange

Expand Post »
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

PHP Syntax (Toggle Plain Text)
  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>
Reputation Points: 24
Solved Threads: 0
Junior Poster in Training
assgar is offline Offline
89 posts
since Oct 2006
Mar 26th, 2008
0

Re: creating a sticky form compatible with onChange

You can do this.
<input type="text" name="firstname" value="<?php echo $_POST['firstname']; >?">
Moderator
Featured Poster
Reputation Points: 524
Solved Threads: 356
Purple hazed!
nav33n is offline Offline
3,878 posts
since Nov 2007
Mar 26th, 2008
0

Re: creating a sticky form compatible with onChange

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:

PHP Syntax (Toggle Plain Text)
  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. ?>
Reputation Points: 24
Solved Threads: 0
Junior Poster in Training
assgar is offline Offline
89 posts
since Oct 2006
Mar 26th, 2008
0

Re: creating a sticky form compatible with onChange

It will work. Why are you checking if $_POST['reason'] is empty ? What is stored in $reason ?
Moderator
Featured Poster
Reputation Points: 524
Solved Threads: 356
Purple hazed!
nav33n is offline Offline
3,878 posts
since Nov 2007
Mar 27th, 2008
0

Re: creating a sticky form compatible with onChange

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.
Reputation Points: 24
Solved Threads: 0
Junior Poster in Training
assgar is offline Offline
89 posts
since Oct 2006
Mar 28th, 2008
0

Re: creating a sticky form compatible with onChange

Then your code seems ok ! I dont see any problem..
Moderator
Featured Poster
Reputation Points: 524
Solved Threads: 356
Purple hazed!
nav33n is offline Offline
3,878 posts
since Nov 2007
May 31st, 2008
0

Re: creating a sticky form compatible with onChange

Thanks for the suggestions I will try it.
Reputation Points: 24
Solved Threads: 0
Junior Poster in Training
assgar is offline Offline
89 posts
since Oct 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Need help fast
Next Thread in PHP Forum Timeline: error in my login page





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC