Button inputs not being posted to server

M

Martin

I have a page with a form in it. There is a submit button that posts
the form to the server.

Inside the form are several inputs of different types (text and
button). The text inputs are being sent to the server but the button
inputs are not.

Can someone tell me why this is happening? Is there any way I can get
the button inputs to be posted?

Thanks.
 
A

Adrienne Boswell

I have a page with a form in it. There is a submit button that posts
the form to the server.

Inside the form are several inputs of different types (text and
button). The text inputs are being sent to the server but the button
inputs are not.

Can someone tell me why this is happening? Is there any way I can get
the button inputs to be posted?

Thanks.

A URL would be helpful.

If the page is not on a public server, or requires login to access, then
just save it (just the markup rendered by the browser), edit it to take
out any sensitive information, and post it somewhere on the Internet.
 
M

Martin

A URL would be helpful.

If the page is not on a public server, or requires login to access, then
just save it (just the markup rendered by the browser), edit it to take
out any sensitive information, and post it somewhere on the Internet.

As a matter of fact, it is not on a public server. It's part of the
user interface on an industrial process.

I accomplished what I needed to by using some javascript to have the
buttons update some "hidden" inputs which are submitted to the server
just fine.

Are you implying that the "button" inputs SHOULD be getting submitted
to the server?
 
B

Beauregard T. Shagnasty

Martin said:
As a matter of fact, it is not on a public server. It's part of the
user interface on an industrial process.

I accomplished what I needed to by using some javascript to have the
buttons update some "hidden" inputs which are submitted to the server
just fine.

...which might work if JavaScript is not disabled. Can you be sure?
Are you implying that the "button" inputs SHOULD be getting submitted
to the server?

First, I'd be curious what kind of data you expect these buttons to
store in your database. Are they:
<input type="button" name="button1" value="1234"> or
<button type="button">Display This Text</button>

<button> usually means 'do an immediate action' while the form is still
running, and there'll be no value to store in the action script.

Since you imply multiple buttons, I'm assuming these are not "submit"
buttons. <input type="submit" ...>
 
M

Martin

Then surely you could publish just the <form> HTML here, or somewhere on
a public server - while snipping any "secret" parts.

OK - see below - at the bottom.
..which might work if JavaScript is not disabled. Can you be sure?

Yes - I'm using a lot of JS in this user interface. The pages are used
only on a LAN and only by a few people. Having JS enabled is a
requirement.
First, I'd be curious what kind of data you expect these buttons to
store in your database. Are they:
<input type="button" name="button1" value="1234"> or
<button type="button">Display This Text</button>

I'm using: said:
<button> usually means 'do an immediate action' while the form is still
running, and there'll be no value to store in the action script.

Since you imply multiple buttons, I'm assuming these are not "submit"
buttons. <input type="submit" ...>

That is correct - they are not "submit" buttons. There is only one of
those.

The purpose of the input buttons is to enable the user to control the
ON/OFF status of a certain feature. Clicking the button changes the
button's color and wording (and also changes its value). When the user
clicks the submit button, the status of the buttons is sent to the
server where it is extracted and used to update some real-world
statuses.

===============================================
There are actually 9 rows in the table below - I've included only the
first 3 here to simplify things a bit.

--------------------------------------------------------------------------------------
Here is the function (in the head of the page) that updates the
buttons appearance and sets the value in the hidden input that I'm
currently using.

<script type='text/javascript'>
function toggleState(item){
x='ONOFF'+item.name.substring(3);
document.getElementById('test').value=x;
if(item.className == 'on') {
item.className='off';
item.value=' OFF ';
document.getElementById(x).value='OFF';
} else {
item.className='on';
item.value=' ON ';
document.getElementById(x).value='ON';
}
}
</script>

</head>

<BODY background='/WebGraphics/background.gif' onload='init();'>
<a name='pagetop'>&nbsp;</a>

<FORM action='RepackSorter.htm' method='post'>

<table width='850px' bgcolor='#f5f5f5' BORDER=1 align='center'
cellpadding=1>
<colgroup><col width='10%' align='center'><col width='10%'
align='center'><col width='10%' align='center'><col width='10%'
align='center'><col width='10%' align='center'><col width='10%'
align='center'><col width='10%' align='center'><col width='10%'
align='center'></colgroup>

<tr><td colspan='8'>REPACK SORTER</td></tr>
<tr><b><td>Divert #</td>
<td>Lane</td>
<td>Status</td>
<td>Mode</td>
<td>Priority</td>
<td>Carrier</td>
<td>Truck</td>
<td>Retail</td>
</b></tr>

<tr><td>1</td>
<td>Table 1</td>
<td>UNKNOWN</td>
<td><INPUT type='hidden' value = 'OFF' name='ONOFF1'><input
type='button' name='btn1' value='OFF' class='off'
onclick='toggleState(this)'></td>
<td>1</td>
<td>&nbsp;</td>
<td>5</td>
</tr>

<tr><td>2</td>
<td>Table 2</td>
<td>UNKNOWN</td>
<td><INPUT type='hidden' value = 'OFF' name='ONOFF2'><input
type='button' name='btn2' value='OFF' class='off'
onclick='toggleState(this)'></td>
<td>2</td>
<td>FEDEX</td>
<td>&nbsp;</td>
</tr>

<tr><td>3</td>
<td>Table 3</td>
<td>UNKNOWN</td>
<td><INPUT type='hidden' value = 'OFF' name='ONOFF3'><input
type='button' name='btn3' value='OFF' class='off'
onclick='toggleState(this)'></td>
<td>3</td>
<td>UPS</td>
<td>&nbsp;</td>
</tr>

</table>

<br /><p align='center'><INPUT type='submit' tabindex='40' value='Save
Changes' name='UPDATE' style='font-weight:bold; text-align:center;
background-color:#C0FFC0; width:177px;'></p>
</FORM>

</body>
</html>
 
R

Raymond Schmit

OK - see below - at the bottom.


Yes - I'm using a lot of JS in this user interface. The pages are used
only on a LAN and only by a few people. Having JS enabled is a
requirement.




That is correct - they are not "submit" buttons. There is only one of
those.

The purpose of the input buttons is to enable the user to control the
ON/OFF status of a certain feature. Clicking the button changes the
button's color and wording (and also changes its value). When the user
clicks the submit button, the status of the buttons is sent to the
server where it is extracted and used to update some real-world
statuses.

perhaps you need one of those:
http://www.htmlcodetutorial.com/forms/_INPUT_TYPE_CHECKBOX.html
http://www.echoecho.com/htmlforms10.htm
http://www.echoecho.com/htmlforms11.htm
 
B

Beauregard T. Shagnasty

Martin said:
OK - see below - at the bottom.




That is correct - they are not "submit" buttons. There is only one of
those.

The purpose of the input buttons is to enable the user to control the
ON/OFF status of a certain feature. Clicking the button changes the
button's color and wording (and also changes its value). When the user
clicks the submit button, the status of the buttons is sent to the
server where it is extracted and used to update some real-world
statuses.

===============================================
There are actually 9 rows in the table below - I've included only the
first 3 here to simplify things a bit.

--------------------------------------------------------------------------------------
Here is the function (in the head of the page) that updates the
buttons appearance and sets the value in the hidden input that I'm
currently using.

<script type='text/javascript'>
function toggleState(item){
x='ONOFF'+item.name.substring(3);
document.getElementById('test').value=x;
if(item.className == 'on') {
item.className='off';
item.value=' OFF ';
document.getElementById(x).value='OFF';
} else {
item.className='on';
item.value=' ON ';
document.getElementById(x).value='ON';
}
}
</script>

</head>

<BODY background='/WebGraphics/background.gif' onload='init();'>
<a name='pagetop'>&nbsp;</a>

<FORM action='RepackSorter.htm' method='post'>

What does 'RepackSorter.htm' do? Is it, say, a server PHP script that
stores form results in a database? Trying to store the "state of a

Raymond has answered with the correct technique. Use checkboxes, radio
buttons, or dropdowns for selection, rather than your over-intricate,
prone-to-error "buttons."
 
D

Denis McMahon

The purpose of the input buttons is to enable the user to control the
ON/OFF status of a certain feature. Clicking the button changes the
button's color and wording (and also changes its value). When the user
clicks the submit button, the status of the buttons is sent to the
server where it is extracted and used to update some real-world
statuses.

Would it be better to use checkboxes? set the boxes to checked when you
create the form if the control it represents is currently "on", and then
when the form is submitted, if a box is checked, set the control on,
otherwise set the control off.

You could also use a pair of radio buttons for each control having the
states on and off.

Rgds

Denis McMahon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,989
Messages
2,570,207
Members
46,782
Latest member
ThomasGex

Latest Threads

Top