Button inputs not being posted to server

Discussion in 'HTML' started by Martin, May 5, 2011.

  1. Martin

    Martin Guest

    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.
     
    Martin, May 5, 2011
    #1
    1. Advertising

  2. Gazing into my crystal ball I observed Martin <>
    writing in news::

    > 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
     
    Adrienne Boswell, May 5, 2011
    #2
    1. Advertising

  3. Martin

    Martin Guest

    On Thu, 5 May 2011 17:34:35 +0000 (UTC), Adrienne Boswell
    <> 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?
     
    Martin, May 5, 2011
    #3
  4. 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
     
    Beauregard T. Shagnasty, May 5, 2011
    #4
  5. Martin

    Martin Guest

    On Thu, 5 May 2011 16:50:32 -0400, "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.

    >> 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>
     
    Martin, May 5, 2011
    #5
  6. On Thu, 05 May 2011 15:04:53 -0700, Martin <>
    wrote:

    >On Thu, 5 May 2011 16:50:32 -0400, "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.
    >
    >>> 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/forms/_INPUT_TYPE_CHECKBOX.html
    http://www.echoecho.com/htmlforms10.htm
    http://www.echoecho.com/htmlforms11.htm
     
    Raymond Schmit, May 5, 2011
    #6
  7. 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
     
    Beauregard T. Shagnasty, May 6, 2011
    #7
  8. 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
     
    Denis McMahon, May 7, 2011
    #8
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. AndyAtHome
    Replies:
    1
    Views:
    602
    AndyAtHome
    May 25, 2004
  2. David Stahl
    Replies:
    2
    Views:
    454
    David Stahl
    Apr 28, 2004
  3. zyaam
    Replies:
    2
    Views:
    359
    Steve C. Orr [MVP, MCSD]
    Dec 29, 2004
  4. =?Utf-8?B?SmF6eg==?=
    Replies:
    5
    Views:
    479
    Bill Gregg
    Apr 28, 2006
  5. coolsti
    Replies:
    4
    Views:
    231
    coolsti
    May 20, 2005
Loading...

Share This Page