Page 1 of 1

Form Anchoring.

Posted: Fri Sep 23, 2005 12:20 pm
by quadoc
Hi, I've a forms with some inputs and one of the inputs is a Drop Down List. What happen is I have to scroll the form down to select from to the Drop Down List and make a selection. When I did this, my form jump back to top like when I first entered the page. I've used anchoring like below but it doesn't look like it's working. Could someone takes a look a the script and let me know what I did wrong. Thanks

Code: Select all

<?php
include "online.php";
?>
<SCRIPT LANGUAGE=javascript>

function selDept(obj)
{
   document.getElementById("hidDept").value=obj.options[obj.options.selectedIndex].value

   if(document.getElementById("hidDept").value!="")
   {					
      document.getElementById ("frmDept").submit()
   } 
}


</SCRIPT>

<form name="frmDept" id="frmDept" method="post" action="http://MyForm.com/NewTicket">
  <input type="hidden" name="hidDept" id="hidDept" value="<? echo $tmpDept; ?>">
</form>

<form name="frmTicket" method="post" enctype="multipart/form-data">

  <table width="650" border="0" align="center" cellpadding="1" cellspacing="1">
    <tr align="left" valign="top"> 
      <td colspan="2">
		<table width="650" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><strong>Submit a support ticket<br>
              </strong><img src="images/submitticket.png" width="54" height="54"></td>
            <td width="45" align="center" valign="top"><a href="index.php?x=home"><img src="images/back.png" width="54" height="54" border="0"><br>
              Back</a></td>
          </tr>
        </table>
      </td>
    </tr>

    <tr align="left" valign="center"> 
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    
	<tr align="left" valign="center"> 
      <td ><font color="#<? echo $fontname ?>">User Name</font></td>
     <td width="450"> 
        <input name="name" type="text" id="name" value="<?php if(isset($_SESSION["name"])){ echo $_SESSION["name"]; } ?>" disabled maxlength="50">
      </td>
    </tr>
    
	<tr align="left" valign="center"> 
      <td width="130"><font color="#<? echo $fontemail ?>">E-mail</font></td>
      <td> <input name="email" type="text" id="email" value="<?php if(isset($_SESSION["email"])){ echo $_SESSION["email"]; } ?>" maxlength="50"></td>
    </tr>
    
<tr align="left" valign="center"> 
      <td width="130"><font color="#<? echo $fontsubject ?>">Subject</font></td>
      <td><input name="subject" type="text" size="60" id="subject" value="<?php if(isset($_SESSION["subject"])){ echo $_SESSION["subject"]; } ?>" maxlength="120"></td>
    </tr>

<a name='$Counter'></a>    

    <tr align="left" valign="center"> 
      <td><br><font color="#<? echo $fontdep ?>">Department</font></td>
      <td><br>
	  <select name="department" id="department" onchange="javascript:selDept(this)">

<!--    <select name="department" id="department" onchange="javascript:putValue()">  -->
 <?php

Posted: Fri Sep 23, 2005 12:47 pm
by feyd
to get to the only anchor I see in the code, you'd have to use a URL like this (literally) foo.php#$Contact php will not parse your variable, if that's what you are after.. :)

Posted: Fri Sep 23, 2005 12:50 pm
by quadoc
so I'd have to make my URL like this?

Code: Select all

<form name="frmDept" id="frmDept" method="post" action="http://MyForm.com/NewTicket#$Counter"> 
  <input type="hidden" name="hidDept" id="hidDept" value="<? echo $tmpDept; ?>"> 
</form>

Posted: Fri Sep 23, 2005 12:53 pm
by feyd
provided http://MyForm.com/NewTicket is the URL of that script..

Posted: Fri Sep 23, 2005 1:01 pm
by quadoc
My other question is I only want this page to scroll down if only the user have made a selection from the Drop Down List though. I don't want it to scroll down when the user first enter the page. How'd I do that?

Posted: Fri Sep 23, 2005 1:28 pm
by feyd
link to it like normal.. no hash