Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 06-04-2005, 07:01 PM   #1
Registered: Sep 2003
Distribution: ubuntu 5.04 knoppix Slack91/10 freebsd51 vector4 redhat9
Posts: 304

Rep: Reputation: 30
javascript: change value of text field and submit without trace?

I am porting my *nix POS restaurant from command line version to web version (once it become stable, I would clear up the code and release it as GPL or MPL soon).

In order to change the work area to desk 7. The command line version would have to type 07[enter], the web version would accept both 07[enter] or 7[desk]. The desk key is in fact the numlock mapped as a comma (keyCode==188). You can see it as 7[comma]. The javascript would take care of the value transformation.

The problem is that when the value of the text field change from "7" to "07", it would appear as "07," or "07" for a very short time.
- I would like only "7" appear in the field while submitting, it is also ok if the value is not visible temporary
- if change the type from "text" to "hidden", it would just disappear and the layout changed
How can I change the value without trace while submitting?

Note: this program use firefox as front end, cache, history, form, saved password all disabled.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ""> <html xmlns="" lang="en" xml:lang="en">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</title><link rel="stylesheet" href="/css/david.css" type="text/css"/></head>
<body onload="javascript:document.cmd.cmd.focus()">
<h1>Program in development</h1><br/>
<script language="javascript" type="text/javascript">
function desknum(event) {
if (event.keyCode==188) {//desknum
if (document.cmd.cmd.value.match(/^\d{1,5}$/i)) {
<form name="cmd" action="?dsk=7" method="post">
desk 7: <br/><input name="cmd" class="cmd" type="text" onkeydown="desknum(event)"/>
<tr class="header"><td/>Qty<td/>Descriptions<td/>Price<td/>Recod</tr><tr class="r0"><td/>1<td/><small>5 </small>GAMBAS FRITAS<td/>5.95<td/>01:30</tr>
<br/>Desk 7:<br/>base 5.56 + tax 0.39 = 5.95<br/>

body {
font-family: sans-serif, Helvetica, Geneva, Arial, SunSans-Regular;
color: black;
div.navtext {
padding-left: 11em;}
ul.navbar {
position: absolute;
top: 2em;
left: 1em;
width: 9em;
list-style-type: none;
padding: 0;
margin: 0;}
ul.navbar li {
background: #DDDDFF;
margin: 0.5em 0;
padding: 0.3em;
border-top: 1px solid blue;
border-bottom: 1px solid blue;}
ul.navbar a {
text-decoration: none }
a:link, a:visited {
color: #000000;
font-weight: bold;
text-decoration: none}
a:hover {
color: white;
font-weight: bold;
background: black}
a:active {
color: white;
font-weight: bold;
small {
color: #663366}
table {
border-collapse: collapse;
border: 3px solid #663366}
tr {
padding: 2em;
border-bottom: 1px solid #663366;
.header {
color: white;
font-weight: bold;
background: #663366}
.r0 {
background: #DDDDDD}
.r1 {
background: #EEEEEE}
td {
border-bottom: 1px solid #663366;
border-left: 1px dotted #663366;
border-right: 1px dotted #663366;
padding-left: 3px;
padding-right: 3px}
input {
border: 1px solid #663366;
padding: 8px;
font-weight: bold;}
.cmd {
font-size: 20px;}
.form {
padding: 3px;
margin-left: 11em;}
select {

Last edited by codec; 06-05-2005 at 02:59 AM.
Old 06-05-2005, 12:47 PM   #2
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 66
Do you mean that you want to display it as 07 but only send 7 to the server? I'd recommend performing this check/change on the server side and not on the client side, it leaves a lot less places for things to go wrong.
Old 06-06-2005, 08:02 AM   #3
Registered: Sep 2003
Distribution: ubuntu 5.04 knoppix Slack91/10 freebsd51 vector4 redhat9
Posts: 304

Original Poster
Rep: Reputation: 30
In a restaurant system. the waiter usually have to input the desk ID and then input the dishes and/or services. They made mistake sometimes mistaking the messing with the desk ID or Plate ID.

In order to solve the problem:
1) desk id is begin with 0 in the command line version. so in order to change the work area to desk 5, they must enter 05.

2) make a custom "desk" key. People enter 5[desk] without enter would do the same job. javascript is required.

If the javascript just transform the same command to type 1. No modification is need in the server side command interpretator. In fact I have 5-7 more keys using the same trick.

Anyway, thanks. If I can't find better way, I may modify the server side code doubleing the code.
Old 06-06-2005, 08:08 AM   #4
Senior Member
Registered: Jul 2004
Location: France
Distribution: Arch Linux
Posts: 1,897

Rep: Reputation: 63
You may be interested in this article:

In there, they explain very well, with very good javascript, how to handle forms with javascript, and how to change text anywhere anytime.



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can we change the submit button look using css pranith Programming 2 07-08-2005 03:54 AM
Can I "submit" an HTML <Form> with Javascript? nickiv Programming 3 06-13-2005 06:41 AM
How to insert same text in one field for 10,000 records table edhan Linux - Newbie 6 06-13-2005 03:48 AM
submit a form with javascript djgerbavore Programming 6 06-01-2005 02:46 PM
Replacing text in a specific field Seventh_Warrior Programming 5 04-11-2005 12:04 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:17 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration