PHP forums, MySQL forums, Web Development resources

Home PageHome    PHP ResourcesTopic List    FAQFAQ    SearchSearch    MemberlistMemberlist    UsergroupsUsergroups 
 RegisterRegister
    ProfileProfile    Log in to check your private messagesLog in to check your private messages    Download the RSS Reader RSS Feed Download the RSS Reader RSS for this forum Log inLog in 

PHP Forum :: MySQL Forum :: Java Script Forum



creating a sticky form compatible with onChange

 
Post new topic   Reply to topic    WeberForums.com Forum Index -> PHP General
View previous topic :: View next topic  
Author Message
assgar



Joined: 25 Oct 2006
Posts: 56

PostPosted: Thu Mar 27, 2008 12:53 am    Post subject: creating a sticky form compatible with onChange Reply with quote

creating a sticky form compatible with onChange

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



Code:


<?
 include("../priority_low_to_high_in.php");//proiority drop down
?>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Calendar</title>
<link href="../config.css" rel="stylesheet" type="text/css"/>
<script language="JavaScript" type="text/JavaScript">
<!--
function OnChange(dropdown)
{
  window.location.href="http://localhost/search_form.php?pro_id=" +
  dropdown.options[dropdown.selectedIndex].value;
}


function MM_reloadPage(init)
 {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
 }
MM_reloadPage(true);
//-->
</script>

<style type="text/css">
<!--

-->
</style>
</head>

<!-----------------------form processor---------------------------->
<form  action="../search_process.php" name="calendar" method="post">

<tr>
 <td>
      <select name= "provider_id" onChange="javascript:OnChange(this);">
       <?   
        //display lastname and first name
        provider_first_last_name_display($name, $name_val, $db_id);
          ?>
      </select>
 </td>
</tr>

<tr>
  <td>
    <!---reason input---->
    <input type="text" name="reason" size="30" maxlength="60" value ="<?php echo $reason; ?>">
  </td>
</tr>

<tr>
  <td>
      <!--priority dropdown-->
      <select name="priority">
    <?php
       $priority_name = get_b_priority_name($b_priority_n);
       $priority_code = get_b_priority_code($b_priority_c);
       for($n = 1; $n<= 6; $n++)
           {
         $sname = $priority_name[$n];
         $scode = $priority_code[$n];
         echo "<option value = '$scode'";
            if ($scode == " ")
                {
                     echo "selected";
                }
         echo "> $sname";
      }
    ?>
         </select>
  </td>
</tr>
</body>
</from>
</html>

Back to top
View user's profile Send private message Send e-mail
lostboy



Joined: 02 May 2004
Posts: 4958
Location: toronto, canada

PostPosted: Thu Mar 27, 2008 3:09 am    Post subject: Reply with quote

The form needs to do an onsubmit, to submit the form to the processing page...in your case you may want to use some AJAX to handle the select boxes, assuming from your description that you are dynamically changing the options based on selections from other boxes
_________________
Lostboy

Cat, the other other white meat

Please read Posting Etiquette before posting

You can always try Google
Back to top
View user's profile Send private message Send e-mail AIM Address MSN Messenger
assgar



Joined: 25 Oct 2006
Posts: 56

PostPosted: Sat Mar 29, 2008 7:43 pm    Post subject: Reply with quote

Hi

Thanks for responding.

I will try Ajax to see if it makes a difference.

FYI. The first dropdown is dynamic using database listings.
The reason input box and the second dropdown are static and are
not dependant or linked to the dynamic dropdown.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
WeberTrivia Questions WeberTrivia Questions
 Think you are smart? Prove it!. Try your skills with these questions :
 WeberTrivia QuestionsRecursive arrays and multi-dimensional arrays are one and the same. (PHP and MySQL)
 WeberTrivia QuestionsThe \"cache_dir\" tag of the squid configuration has a default of /var/spool/squid. (Linux)

WeberTrivia Questions



PHP Code Examples
 Stream diffrent sizes of images from a single image to save disk space.
 JavaScript dropdown list menu to switch any page.
 Dump the contents of a PHP variable in html format with a recursive list of subfolders and files from a given root directory.
 PHP Dump in html format the contents of one array variable with a recursive list of the nested array variables inside.
 Link Extractor - This function is used to extract links from a given URL. This will convert relative path into absolute path and also remove PHPSESSID stuff.
 Building a Dynamic Form using Javascript and innerHTML. Add form elements in realtime without refreshing the page.
 A PHP Calendar function with CSS : add a cool calendar to any php page by just adding a calendar class based function.
Post new topic   Reply to topic    WeberForums.com Forum Index -> PHP General All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum






Powered by phpBB © 2001, 2005 phpBB Group
PHP Forum :: MySQL Forum :: Java Script Forum