Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newbie needs help 1

Status
Not open for further replies.

tyrannus

MIS
Apr 6, 2006
115
US
I have a client that insists the use of the return key rather than the tab key to switch from field to field on an html form. I have searched and can find nothing in HTML that will do this. IS there anything in JS that can do that?
 
Ok used the example with a slight modification. And it works great in firefox, but in IE it doesn't

script:
<SCRIPT>
function handleEnter (field, event) {
var keyCode = event.keyCode ? event.keyCode :
event.which ? event.which : event.charCode;
if (keyCode == 13) {
var i;
for (i = 0; i < 45; i++)
if (field == field.form.elements)
break;
i = (i + 1) % field.form.elements.length;
field.form.elements.focus();
return false;
}
else
return true;
}
</SCRIPT>

Then on each element I am doing onkeypress"return handleEnter(this, event)"

In IE, when I hit return/enter, it does nothing it stops and the cursor goes away.. Any thoughts?
 
The script works fine for me in IE. Can only guess why it doesn't work with out the rest of the html. Could be because your input elements are not in form tags.
 
here is the full script
<?php
// $link = mysql_connect("localhost", "user", "password") or die("Error: Could not connect");
// mysql_select_db("db") or die("Error:Could not select database");

if ($submit == "Send")
{
$zaction = "send";
} else {
$zaction = "form";
}

?>


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
<meta name="generator" content="Adobe GoLive 6">
<title>Fagen Pharmacy Promo Request Form</title>


<SCRIPT>
function handleEnter (field, event) {
var keyCode = event.keyCode ? event.keyCode :
event.which ? event.which : event.charCode;
if (keyCode == 13) {
var i;
for (i = 0; i < 45; i++)
if (field == field.form.elements)
break;
i = (i + 1) % field.form.elements.length;
field.form.elements.focus();
return false;
}
else
return true;
}
</SCRIPT>


</head>

<body bgcolor="#ffffff">
<div align="center">
<p><img src="/images1/fagen_to_jpeg.gif" alt="" width="406" height="179" border="0"><br>
<img src="/images1/line.jpg" alt="" width="500" height="3" border="0"><br>
<font size="5" color="#d60021" face="Arial"><u>Promo Request Form</u></font><font color="#d60021"><br>
</font><img src="../images_admin/line.jpg" alt="" width="500" height="3" border="0"><br>


<img src="/images1/line.jpg" alt="" width="500" height="3" border="0"><br>
<br>
<?
if ($zaction=='form')
{ ?><font color="#d60021" face="Arial" size="5">New Entry</font>
<?
form();
}
if ($zaction=='send')
{
send($_POST);
echo "<h1>Message Sent</h1>\n\n";
}
?><br>
<img src="/images1/line.jpg" alt="" width="500" height="3" border="0"><br>
<table width="479" border="0" cellspacing="0" cellpadding="0" cool gridx="16" gridy="16" height="31" showgridx showgridy usegridx usegridy>
<tr height="30">
<td width="320" height="30" valign="top" align="left" xpos="0"><a href="/index1.html"><img src="images1/mainmenu.gif" alt="" width="155" height="30" border="0"></a></td>
<td width="158" height="30" valign="top" align="left" xpos="320"><a href="/admin"><img src="images1/adminmenu.gif" alt="" width="155" height="30" border="0"></a></td>
<td width="1" height="30"><spacer type="block" width="1" height="30"></td>
</tr>
<tr height="1" cntrlrow>
<td width="320" height="1"><spacer type="block" width="320" height="1"></td>
<td width="158" height="1"><spacer type="block" width="158" height="1"></td>
<td width="1" height="1"></td>
</tr>
</table>
<br>

All information contained within is propriatory and may not be transmited, duplicated,<br>
or shown without prior written consent from Fagen Pharmacy.</div>
</body>

</html>

<?
function send($POST)
{
$to="promos@fagenpharmacy.com";
$from="promos@fagenpharmacy.com";
$promo=$POST['promo'];
$subject="Promo Request ".$POST['promo'];
$include=$POST['include'];
$startdate=$POST['startdate'];
$enddate=$POST['enddate'];
$upccode=$POST['upccode'];
$vendor=$POST['vendor'];
$price=$POST['price'];
$saleprice2=$POST['saleprice2'];
$upccode2=$POST['upccode2'];
$vendor2=$POST['vendor2'];
$price2=$POST['price2'];
$saleprice2=$POST['saleprice2'];
$upccode3=$POST['upccode3'];
$vendor3=$POST['vendor3'];
$price3=$POST['price3'];
$saleprice3=$POST['saleprice3'];
$upccode4=$POST['upccode4'];
$vendor4=$POST['vendor4'];
$price4=$POST['price4'];
$saleprice4=$POST['saleprice4'];
$upccode5=$POST['upccode5'];
$vendor5=$POST['vendor5'];
$price5=$POST['price5'];
$saleprice5=$POST['saleprice5'];
$upccode6=$POST['upccode6'];
$vendor6=$POST['vendor6'];
$price6=$POST['price6'];
$saleprice6=$POST['saleprice6'];
$upccode7=$POST['upccode7'];
$vendor7=$POST['vendor7'];
$price7=$POST['price7'];
$saleprice7=$POST['saleprice7'];
$upccode8=$POST['upccode8'];
$vendor8=$POST['vendor8'];
$price8=$POST['price8'];
$saleprice8=$POST['saleprice8'];
$upccode9=$POST['upccode9'];
$vendor9=$POST['vendor9'];
$price9=$POST['price9'];
$saleprice9=$POST['saleprice9'];
$comment=$POST['comment'];
$submitted=$POST['submitted'];
$msgg2="";
$msgg3="";
$msgg4="";
$msgg5="";
$msgg6="";
$msgg7="";
$msgg8="";
$msgg9="";
if ($upccode2 != null)
{
$msgg2="\nItem #2 : ".$POST['upccode2']." : ".$POST['vendor2']." : ".$POST['price2']." : ".$POST['saleprice2'];
}
if ($upccode3 != null)
{
$msgg3="\nItem #3 : ".$POST['upccode3']." : ".$POST['vendor3']." : ".$POST['price3']." : ".$POST['saleprice3'];
}
if ($upccode4 != null)
{
$msgg4="\nItem #4 : ".$POST['upccode4']." : ".$POST['vendor4']." : ".$POST['price4']." : ".$POST['saleprice4'];
}
if ($upccode5 != null)
{
$msgg5="\nItem #5 : ".$POST['upccode5']." : ".$POST['vendor5']." : ".$POST['price5']." : ".$POST['saleprice5'];
}
if ($upccode6 != null)
{
$msgg6="\nItem #6 : ".$POST['upccode6']." : ".$POST['vendor6']." : ".$POST['price6']." : ".$POST['saleprice6'];
}
if ($upccode7 != null)
{
$msgg7="\nItem #7 : ".$POST['upccode7']." : ".$POST['vendor7']." : ".$POST['price7']." : ".$POST['saleprice7'];
}
if ($upccode8 != null)
{
$msgg8="\nItem #8 : ".$POST['upccode8']." : ".$POST['vendor8']." : ".$POST['price8']." : ".$POST['saleprice8'];
}
if ($upccode9 != null)
{
$msgg9="\nItem #9 : ".$POST['upccode9']." : ".$POST['vendor9']." : ".$POST['price9']." : ".$POST['saleprice9'];
}

$message="\nFagen Promo Request\n\nPromo Name : ".$POST['promo'].
"\nRequest By : ".$POST['submitted'].
"\nStore Number : ".$POST['store_number'].
"\nIncludes Stores: ".$POST['include'].
"\nStarting On : ".$POST['startdate'].
"\nEnding On : ".$POST['enddate'].
"\n : UPC CODE : Vendor : Price : Sale Price\nItem #1 : ".$POST['upccode']." : ".$POST['vendor']." : ".$POST['price']." : ".$POST['saleprice'].
"$msgg2$msgg3$msgg4$msgg5$msgg6$msgg7$msgg8$msgg9\n\nComments: ".$POST['comment'];
mail_notice($to,$from,$subject,$message);
}

function form()
{
?>
<form name="myform" action="<? echo $PHP_SELF; ?>" method="post">
<table>
<!-- <tr>
<td>Store Name:</td>
<td><input type="text" name="store_name" value="Fagen Pharmacy" size="40"></td>
</tr>
-->
<tr>
<td>Store # Requesting Promo:</td>
<td><select name="store_number">
<option>1</option>
<option>2</option>
<option>3</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>11</option>
<option>14</option>
<option>15</option>
<option>17</option>
<option>18</option>
<option>20</option>
<option>22</option>
<option>23</option>
<option>25</option>
<option>26</option>
<option>27</option>
<option>28</option>
<option>31</option>
<option>32</option>
<option>33</option>
<option>35</option>
<option>36</option>
<option>62</option>
</select>
</td>
</tr>
<tr>
<td>Promo Includes These Stores:</td>
<td><input type="text" ONKEYPRESS="return handleEnter(this, event)" name="include" size="40"></td>
</tr>
<tr>
<td>Promo Name (No Spaces):</td>
<td><input type="text" ONKEYPRESS="return handleEnter(this, event)" name="promo" size="40"></td>
</tr>
<tr>
<td>Start Date MM/DD/YYYY:</td>
<td><input type="text" ONKEYPRESS="return handleEnter(this, event)" name="startdate" size="12" value="MM/DD/YYYY"></td>
</tr>
<tr>
<td>End Date MM/DD/YYYY:</td>
<td><input type="text" ONKEYPRESS="return handleEnter(this, event)" name="enddate" size="12" value="MM/DD/YYYY"></td>
</tr>

<tr>
<td>UPC Code (Required):</td>
<td> Vendor Name ______________ Price __________ Sale Price ___________</td>
</tr>
<tr>
<td>Item #1:<input type="text" ONKEYPRESS="return handleEnter(this, event)" name="upccode" size="14"></td>
<td> <input type="text" ONKEYPRESS="return handleEnter(this, event)" name="vendor" size="30">
<input type="text" ONKEYPRESS="return handleEnter(this, event)" name="price" size="14">
<input type="text" ONKEYPRESS="return handleEnter(this, event)" name="saleprice" size="30"></td>
</tr>
<tr>
<td>Item #2:<input type="text" ONKEYPRESS="return handleEnter(this, event)" name="upccode2" size="14"></td>
<td> <input type="text" ONKEYPRESS="return handleEnter(this, event)" name="vendor2" size="30">
<input type="text" ONKEYPRESS="return handleEnter(this, event)" name="price2" size="14">
<input type="text" ONKEYPRESS="return handleEnter(this, event)" name="saleprice2" size="30"></td>
</tr>
<tr>
<td>Item #3:<input type="text" ONKEYPRESS="return handleEnter(this, event)" name="upccode3" size="14"></td>
<td> <input type="text" ONKEYPRESS="return handleEnter(this, event)" name="vendor3" size="30">
<input type="text" ONKEYPRESS="return handleEnter(this, event)" name="price3" size="14">
<input type="text" ONKEYPRESS="return handleEnter(this, event)" name="saleprice3" size="30"></td>
</tr>
<tr>
<td>Item #4:<input type="text" ONKEYPRESS="return handleEnter(this, event)" name="upccode4" size="14"></td>
<td> <input type="text" ONKEYPRESS="return handleEnter(this, event)" name="vendor4" size="30">
<input type="text" ONKEYPRESS="return handleEnter(this, event)" name="price4" size="14">
<input type="text" ONKEYPRESS="return handleEnter(this, event)" name="saleprice4" size="30"></td>
</tr>
<tr>
<td>Item #5:<input type="text" ONKEYPRESS="return handleEnter(this, event)" name="upccode5" size="14"></td>
<td> <input type="text" ONKEYPRESS="return handleEnter(this, event)" name="vendor5" size="30">
<input type="text" ONKEYPRESS="return handleEnter(this, event)" name="price5" size="14">
<input type="text" ONKEYPRESS="return handleEnter(this, event)" name="saleprice5" size="30"></td>
</tr>
<tr>
<td>Item #6:<input type="text" ONKEYPRESS="return handleEnter(this, event)" name="upccode6" size="14"></td>
<td> <input type="text" ONKEYPRESS="return handleEnter(this, event)" name="vendor6" size="30">
<input type="text" ONKEYPRESS="return handleEnter(this, event)" name="price6" size="14">
<input type="text" ONKEYPRESS="return handleEnter(this, event)" name="saleprice6" size="30"></td>
</tr>
<tr>
<td>Item #7:<input type="text" ONKEYPRESS="return handleEnter(this, event)" name="upccode7" size="14"></td>
<td> <input type="text" ONKEYPRESS="return handleEnter(this, event)" name="vendor7" size="30">
<input type="text" ONKEYPRESS="return handleEnter(this, event)" name="price7" size="14">
<input type="text" ONKEYPRESS="return handleEnter(this, event)" name="saleprice7" size="30"></td>
</tr>
<tr>
<td>Item #8:<input type="text" ONKEYPRESS="return handleEnter(this, event)" name="upccode8" size="14"></td>
<td> <input type="text" ONKEYPRESS="return handleEnter(this, event)" name="vendor8" size="30">
<input type="text" ONKEYPRESS="return handleEnter(this, event)" name="price8" size="14">
<input type="text" ONKEYPRESS="return handleEnter(this, event)" name="saleprice8" size="30"></td>
</tr>
<tr>
<td>Item #9:<input type="text" ONKEYPRESS="return handleEnter(this, event)" name="upccode9" size="14"></td>
<td> <input type="text" ONKEYPRESS="return handleEnter(this, event)" name="vendor9" size="30">
<input type="text" ONKEYPRESS="return handleEnter(this, event)" name="price9" size="14">
<input type="text" ONKEYPRESS="return handleEnter(this, event)" name="saleprice9" size="30"></td>
</tr>
<tr>
<td>Amount markdown, Percentage</td><td> Off, BOGO, Mix and Match Promo, Etc.</td>
</tr>
<tr>
<td>If multi unit discount would need </td><td> to know - Buy 3 for 9.99</td>
</tr>
<tr>
<td>Submitted By (Required):</td>
<td><input type="text" ONKEYPRESS="return handleEnter(this, event)" name="submitted" size="40"></td>
</tr>
<tr>
<td>Comments:</td>
<td><textarea cols="40" rows="5" ONKEYPRESS="return handleEnter(this, event)" name="comment"></textarea></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="Mysubmit" value="Send"><input type="reset" value="Clear"></td>
</tr>
</table>
</form>
<? }

function mail_notice($to,$from,$subject,$message)
{
$email = $to;
mail ($email,$subject,$message,
"From: $from\r\n" .
"Reply-To: $from\r\n" .
"X-Mailer: PHP/" . phpversion());
}

function filter_html($text)
{
// First strip all html tags
$text=strip_tags($text);
return $text;
}

function format_timestamp($ts)
{
return substr($ts,4,2)."/".substr($ts,6,2)."/".substr($ts,0,4)." ".
substr($ts,8,2).":".substr($ts,10,2).":".substr($ts,12,2);
}

?>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top