...

View Full Version : form question, please help



vadertech
03-11-2005, 04:31 AM
hi, this is my first post on this forum. I was given a project at work to create a form with 4 fields that posts to a mysql database. I did this no problem. What will be happening is the form will be used with a hand held scanner called pocket pc which has a web browser which will access the form and when a barcode is scanned, the info is entered into the form in plain text and sent to the database. The tricky thing is, the 4 fields (Part number, PO number, Order number and Serial Number) will all be the same for every barcode scanned. The only field that will change is serial_number. So instead of having to rescan the part number, PO number, and Order number barcodes repeatedly, u just scan them once and then u can submit the data and just scan the serial number barcode and keep resubmitting the data. What I'm looking for is a way to reset the serial_number field and focus to that field automatically each time the submit button is hit.

Any help is greatly appreciated for I am in much need of guidance when it comes to coding. I got as far as I could without asking for help.

Thanks in advance.

This is what I am using

form.html

<html>
<head>
<title>CRS</title>
<script>
<!--
function sf(){kit.serial_number.focus();}
// -->
</script>
<script>
function checkrequired(which){
var pass=true
if (document.images){
for (i=0;i<which.length;i++){
var tempobj=which.elements[i]
if (tempobj.name.substring(0,8)=="required"){
if (((tempobj.type=="text"||tempobj.type=="textarea")&&tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&tempobj.selectedIndex==-1)){
pass=false
break
}
}
}
}
if (!pass){
alert("One or more of the required elements are not completed. Please complete them, then submit again!")
return false
}
else
return true
}
</script>
</head>
<body onLoad=sf() bgcolor="#000000">
<center><b><font color="#FFFFFF" face="Arial" size="2">System Integration</font></b>

<form NAME="kit" action=process.php method=GET onSubmit="return checkrequired(this)">
<font face="Arial">
<font size="1" name="arial" color="#FFFFFF">Serial Number:</font><font size="1" color="#FFFFFF">
</font></font> <br>
<input type=text name=requiredserial_number size=20 maxlength=16 style="font-size: 8pt"><br>
<font face="Arial">
<font size="1" name="arial" color="#FFFFFF">Order Number:</font><font size="1" color="#FFFFFF">
</font></font> <br>
<input type=text name=requiredorder_number size=20 maxlength=6 style="font-size: 8pt"><br>
<font face="Arial">
<font size="1" name="arial" color="#FFFFFF">PO Number:</font><font size="1" color="#FFFFFF">
</font></font> <br>
<input type=text name=requiredpo_number size=20 maxlength=7 style="font-size: 8pt"><br>
<font face="Arial">
<font size="1" name="arial" color="#FFFFFF">Part Number:</font><font size="1" color="#FFFFFF">
</font></font> <br>
<input type=text name=requiredpart_number size=20 maxlength=10 style="font-size: 8pt"><br>
<input type=submit value="Send Data" style="font-size: 10px; font-family: Arial">&nbsp;&nbsp;&nbsp;&nbsp;<input type=reset value="Clear Form" style="font-size: 10px; font-family: Arial"><br>
</form>

</center>
</body>
</html>



process.php

<html>

<?php

mysql_connect ("localhost", "username", "password");
mysql_select_db ("crs");
mysql_query ("INSERT into crs (order_number, po_number, part_number, serial_number)
VALUES ('$_GET[order_number]', '$_GET[po_number]', '$_GET[part_number]', '$_GET[serial_number]')
");
?>
<body bgcolor="#000000">
<p align="center"><b><font face="Arial" color="#FFFFFF">SUCCESS!</font></b></p>
<p align="center">&nbsp;<input type=button value="Back" onClick="history.go(-1)" style="font-family: Arial; font-size: 10px"></p>
</body>
</html>

rwedge
03-14-2005, 06:40 AM
This may be all you need to change in the html file:

<script>
<!--
function sf(){
kit.requiredserial_number.value='';
kit.requiredserial_number.focus();}
// -->
</script>

You also need to use the complete form input names in the PHP script by adding required to them.

/Bob



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum