Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   HTML (http://www.velocityreviews.com/forums/f31-html.html)
-   -   Button inputs not being posted to server (http://www.velocityreviews.com/forums/t747813-button-inputs-not-being-posted-to-server.html)

Martin 05-05-2011 04:12 PM

Button inputs not being posted to server
 
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.

Adrienne Boswell 05-05-2011 05:34 PM

Re: Button inputs not being posted to server
 
Gazing into my crystal ball I observed Martin <ironwoodcanyon@gmail.com>
writing in news:c0j5s6hedh9lai3d6u7qm9rsaob9pg7bis@4ax.com:

> 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.

--
Adrienne Boswell at Home
Arbpen Web Site Design Services
http://www.cavalcade-of-coding.info
Please respond to the group so others can share

Martin 05-05-2011 07:11 PM

Re: Button inputs not being posted to server
 
On Thu, 5 May 2011 17:34:35 +0000 (UTC), Adrienne Boswell
<arbpen@yahoo.com> wrote:

>
>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?

Beauregard T. Shagnasty 05-05-2011 08:50 PM

Re: Button inputs not being posted to server
 
Martin wrote:

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


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

> 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" ...>

--
-bts
-Four wheels carry the body; two wheels move the soul

Martin 05-05-2011 10:04 PM

Re: Button inputs not being posted to server
 
On Thu, 5 May 2011 16:50:32 -0400, "Beauregard T. Shagnasty"
<a.nony.mous@example.invalid> wrote:

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

>
>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.

>> 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?


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.

>> 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>


I'm using: <input type="button" name="button1" value="1234">

><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>


Raymond Schmit 05-05-2011 10:54 PM

Re: Button inputs not being posted to server
 
On Thu, 05 May 2011 15:04:53 -0700, Martin <ironwoodcanyon@gmail.com>
wrote:

>On Thu, 5 May 2011 16:50:32 -0400, "Beauregard T. Shagnasty"
><a.nony.mous@example.invalid> wrote:
>
>>Martin wrote:
>>
>>> As a matter of fact, it is not on a public server. It's part of the
>>> user interface on an industrial process.

>>
>>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.
>
>>> 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?

>
>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.
>
>>> 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>

>
>I'm using: <input type="button" name="button1" value="1234">
>
>><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.


perhaps you need one of those:
http://www.htmlcodetutorial.com/form..._CHECKBOX.html
http://www.echoecho.com/htmlforms10.htm
http://www.echoecho.com/htmlforms11.htm

Beauregard T. Shagnasty 05-05-2011 11:44 PM

Re: Button inputs not being posted to server
 
Martin wrote:

> "Beauregard T. Shagnasty" wrote:
>> Martin wrote:
>>> As a matter of fact, it is not on a public server. It's part of the
>>> user interface on an industrial process.

>>
>> 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.
>
>>> 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>

>
> I'm using: <input type="button" name="button1" value="1234">
>
>><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'>


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
<button>" in a database seems counter-productive to me.

> [snip]


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

--
-bts
-Four wheels carry the body; two wheels move the soul

Denis McMahon 05-06-2011 11:18 PM

Re: Button inputs not being posted to server
 
On Thu, 05 May 2011 15:04:53 -0700, Martin wrote:

> 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


All times are GMT. The time now is 05:49 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.