Jump to content

javascript and sticky page


assgar

Recommended Posts

Hello

 

I am new to JavaScript and need some assistance.

 

I am trying to create a page/form

where the user enters first and last name and select their title (Mr, Miss or Mrs).

 

There is also the ability to select 1 of 2 options by clicking a link.

 

After the name, title and option is selected the data is sent to the database using a submit button

 

The problem is when the link is selected and page refreshes and all the data is lost because the sticky page is not working.

 

 

<?
/**
   page: page_list_form.php
**/

include("../reqin/title_in.php");//title drop down

$option = $_REQUEST['u_source_id'];
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- <!DOCTYPE html PUBLIC "-//W3C/DTD//xhtml 1.0 transitional//EN"
  "http://www.w3.org/tr/xthtml1-transitional.dtd"> -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content="HTML Tidy for Linux (vers 6 November 2007), see www.w3.org" />
<title></title>

<script type="text/javascript">
//<![CDATA[

   function OnClick()
    {
      var title = document.getElementById('TitleId').value;

      calForm = document.getElementById("calendar");
      calForm.setAttribute("action", "<?=$_SERVER['PHP_SELF']?>?u_title="+title);

      calForm.submit(); // submit it, keeping POST vars

    }


//]]>
</script>

</head>
<body>
<form id="calendar" action="process.php>" method="post">

<?

echo"<table><tr>
      <td width='30%'>
         <input type='text' name='first_name' value='$first_name' width='95%'/></td>";

echo"<td width='30%'>
        <input type='text' name='last_name' value='$last_name' width='95%'/></td>

      <td width='30%'>";
           title($code);//dropdown with titles
echo" 
  </td>
  <td>";

      /**display option selection**/
      if($option == "p1")
          {
            echo"Option One";
          }
         elseif($option == "p2")
          {
            echo"Option Two";
          }

echo"<input type='hidden' name='option' value='$option'/>";//option value passed to database

echo"</td></tr>
<tr>";

/**link to select and refresh page and keep title, first & last name **/
echo"
     <td><div id='blue-listing'><a href ='../page_list_form.php?u_source_id=p1' onclick='javascript:OnClick();'>Option 1</a></div></td>
     <td><div id='blue-listing'><a href ='../page_list_form.php?u_source_id=p2' onclick='javascript:OnClick();'>Option 2</a></div></td>
     <td> </td>";

/** submit data to database**/
echo"<td><input type='submit' name='Submit'/></td>

  </tr></table>";

?>

</form>
</body>
</html>

Link to comment
Share on other sites

 

Hello

 

I have made some changes that provise some hope.

 

When I select the link the sticky form works and the values are not lost. 

The url display the value for the selected option.  The is problem I am now having is with the

$option = $_REQUEST['u_source_id']; 

 

it is not receiving the url value.  The php if statement is not displaying the information related to the user selection.

 

<?
/**
   page: page_list_form.php
**/

include("../reqin/title_in.php");//title drop down

$option = $_REQUEST['u_source_id'];
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- <!DOCTYPE html PUBLIC "-//W3C/DTD//xhtml 1.0 transitional//EN"
  "http://www.w3.org/tr/xthtml1-transitional.dtd"> -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content="HTML Tidy for Linux (vers 6 November 2007), see www.w3.org" />
<title></title>

<script type="text/javascript">
//<![CDATA[

function()
    {
    	document.getElementById('op_link').onclick = function()
    	  {
    	  	var form;
    	  	form = document.getElementById('calendar');
    	  	form.elements.link = this.href;
    	  	form.submit();
    	  };
    }

//]]>
</script>

</head>
<body>
<form id="calendar" action="process.php>" method="post">

<?

echo"<table><tr>
      <td width='30%'>
         <input type='text' name='first_name' value='$first_name' width='95%'/></td>";

echo"<td width='30%'>
        <input type='text' name='last_name' value='$last_name' width='95%'/></td>
      <td width='30%'>";
           title($code);//dropdown with titles
echo" </td>
  <td>";

      /**display option selection**/
      if($option == "p1")
          {
            echo"Option One";
          }
         elseif($option == "p2")
          {
            echo"Option Two";
          }

echo"<input type='hidden' name='option' value='$option'/>";//option value passed to database

echo"</td></tr>
<tr>";

/**link to select and refresh page and keep title, first & last name **/

/** submit data to database**/
echo"<td><input type='submit' name='Submit'/></td>

  </tr></table>";

?>

</form>
</body>
</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.