www.webdeveloper.com
Results 1 to 2 of 2

Thread: how to see if an element is shown or hidden & set a field when submitting

  1. #1
    Join Date
    Apr 2005
    Posts
    5

    Question how to see if an element is shown or hidden & set a field when submitting

    Hi,

    i've got the following:

    people can either pick an item from a drop down list, or open a table and fill out some fields. Whatever they've done, it is written away to a cookie.

    This works.

    What I would like extra and which I can't get to work is that when the submit button is hit, a form field gets a value as to whether the table was opened or not at the time of submitting.

    You see, I would actually like the form fields in the table to stay populated with the input they once have given (if at all) but if the table was not opened when submitted, then one form field should say so (so I know to just look at the drop down value).

    The code to hide/show the table is this:
    Code:
    function flipper(theTable)
    {
    var x=document.getElementById("city");
    if (document.getElementById(text).style.display == 'none')
       {
       document.getElementById(text).style.display = 'block';
       x.disabled=true;
       txt="coordinaten";
       document.forms[0].geheim.value=txt;
       }
       else
       {
       document.getElementById(text).style.display = 'none';
       x.disabled=false;
       txt="plaats";
       document.forms[0].geheim.value=txt;
       }
    }
    and it sets the 'geheim' form field, but only if the state (show/hide) has been changed.

    Thing is, the geheim form field is default on "plaats", but it will somehow change to "coordinaten" when one hits submit if that has been selected once. But only if the table state (show hide) has not been change this time.

    You can see it in action here:
    http://www.allesoversterrenkunde.nl/test/poa.html

  2. #2
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    If JavaScript were disabled you would check if returned values were empty. No need for even more JavaScript, check server side.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles