Skip to content

Instantly share code, notes, and snippets.

@insidenothing
Last active April 18, 2020 23:41
Show Gist options
  • Save insidenothing/0388cb5c0bf53025dcac004ac815d8e3 to your computer and use it in GitHub Desktop.
Save insidenothing/0388cb5c0bf53025dcac004ac815d8e3 to your computer and use it in GitHub Desktop.
<?PHP
if (isset($_POST['document']) && isset($_POST['text1'])){
// do stuff
}
?>
<script>
function getObject(obj) {
var theObj;
if(document.all) {
if(typeof obj=="string") {
return document.all(obj);
} else {
return obj.style;
}
}
if(document.getElementById) {
if(typeof obj=="string") {
return document.getElementById(obj);
} else {
return obj.style;
}
}
return null;
}
function toCheck(entrance) {
var entranceObj=getObject(entrance);
var mystring=entranceObj.value;
if (mystring.match(/%$/)) {
//alert("autoSubmit barcode");
document.form1.submit();
}
;
}
function toCount(entrance,exit,text,characters) {
var entranceObj=getObject(entrance);
var exitObj=getObject(exit);
var length=characters - entranceObj.value.length;
toCheck(entrance);
if(length == 0) {
// target matched
//alert('ping');
document.form1.submit();
}
if(length <= 0) {
length=0;
text='<span class="disable"> '+text+' </span>';
entranceObj.value=entranceObj.value.substr(0,characters);
}
exitObj.innerHTML = text.replace("{CHAR}",length);
}
string="";
function app(cc) {
string+=cc;
document.form1.text1.value=string;
toCount('text1','sBann','{CHAR} bytes left',13);
}
function clear() {
string="";
document.form1.text1.value=string;
}
function calc() {
if(string.length > 0) {
inp="out="+string;
eval(inp);
} else out="0";
document.form1.text1.value=out;
string=""+out;
}
function upda() {
string=""+document.form1.text1.value;
//window.location.href='?logic='+document.form1.text1.value;
}
function upda2() {
string=""+document.form1.text1.value;
}
</script>
<body onLoad="clear()">
<form action="docutrack_lite.php" name="form1" id="form1" method="POST"
onSubmit="{calc(); return false;}">
<table class="center" width="100%" border="1">
<tr>
<td style="padding:20px;">Enter the common description for the paperwork you are tracking</td>
<td style="padding:20px;"><input id='document' name='document' size="40" value="<?PHP if (isset($_POST['document'])){ echo $_POST['document'];}?>" onChange="checkdocumentName();"></td>
</tr>
</table>
<table class="center" width="100%" border="1">
<tr>
<td style="padding:20px;">Scan PST Document Barcode (MWS2016000001)<br>
<input disabled="true" name="text1"
onKeyUp="toCount('text1','sBann','{CHAR} characters left',13);"
id="text1" value="" onChange="upda()">
</td>
<td style="padding:20px;">
<span id="sBann" class="minitext">13 bytes left.</span>
</td>
</tr>
</table>
<script>checkdocumentName();</script>
</form>
<script>document.form1.text1.focus()</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment