Hidden Values

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • anonymousstar
    New Member
    • Mar 2008
    • 15

    Hidden Values

    Hi all,

    I am new to these forums and decided to join one (this one) after 5 days of researching to try and solve my problem.

    I am creating a booking type of calendar. It will be run by an oracle database. From the front end a user will see all the dates that are available (green cells), dates that are pending (orange cells) and dates that are booked (red cells); the user will then click on the dates that are available they want to book, this will turn to yellow, if they change their mind it will turn back to green. This part I am fine with.

    The problem I have is with the hidden fields. I would like to change the value of the hidden field from "1, 2" to "1, 2 selected" when the user has clicked on a date. When the page refreshes I would still like the yellow cell to appear and not default back to green. Basically I want to know what dates the user has selected and for the value to go into a database.

    I hope I have made sense of what I am trying to do. Any help would be great my code so far is below.

    [HTML]<head>
    <style type="text/css">
    td{width:50px; height:20px; background-color:#009933;}
    </style>
    <script>
    function changeColor(obj TD)
    {
    if(objTD.clicke d)
    {
    objTD.style.bac kgroundColor = "009933";
    objTD.clicked=f alse;
    }
    else
    {
    objTD.style.bac kgroundColor="F FFF00";
    objTD.clicked=t rue;
    }
    }

    </script>
    </head>

    <body>
    <form name="check" action="">
    <table>
    <tr>
    <td id="r1w1" onClick="change Color(this)"><i nput type="hidden" id="r1w1b" name="r1w1" value="1,1"></td>
    <td id="r1w2" onClick="change Color(this)"><i nput type="hidden" id="r1w2b" name="r1w2" value="1,2"></td>
    <td id="r1w3" onClick="change Color(this)"><i nput type="hidden" id="r1w3b" name="r1w3" value="1,3"></td>
    <td id="r1w4" onClick="change Color(this)"><i nput type="hidden" id="r1w4b" name="r1w4" value="1,4"></td>
    </tr>
    </table>
    </form>
    </body>[/HTML]
    Last edited by acoder; Mar 2 '08, 01:42 PM. Reason: Added code tags
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Originally posted by anonymousstar
    I am new to these forums and decided to join one (this one) after 5 days of researching to try and solve my problem.
    Welcome to TSDN!

    Originally posted by anonymousstar
    The problem I have is with the hidden fields. I would like to change the value of the hidden field from "1, 2" to "1, 2 selected" when the user has clicked on a date. When the page refreshes I would still like the yellow cell to appear and not default back to green. Basically I want to know what dates the user has selected and for the value to go into a database.
    When you say refresh, do you mean after submitting the form or if the user presses, say, F5?

    If it's after submitting, the server-side code should deal with that by adding to the database and showing the correct colour.

    If it's after refresh, you'll need cookies to store the information when a cell is clicked on. See this link on cookies.

    Comment

    • anonymousstar
      New Member
      • Mar 2008
      • 15

      #3
      Originally posted by acoder
      Welcome to TSDN!

      When you say refresh, do you mean after submitting the form or if the user presses, say, F5?

      If it's after submitting, the server-side code should deal with that by adding to the database and showing the correct colour.

      If it's after refresh, you'll need cookies to store the information when a cell is clicked on. See this link on cookies.
      Hiya,

      Thank you for your welcome.

      The user will need to select a different part of a calendar which will be a new page and not submitted so I think cookies will be the best answer as I assume it will hold the values until he confirms the dates.

      What I wanted to know is how to change the value of the hidden field so that I can see what the user has selected. 1,2 is the co-ordinates of the cell. row 1, cell 2 and so on. when they select that cell I would like to concantenate selected onto the 1,2 string. I had this example before but when I went to view the source I did not see a change. Is this because I need to use cookies? The code to change the values is below.

      Thank you so much for your help.

      Kind regards

      anonymousstar

      document.getEle mentByID().valu e= " + selected";

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Originally posted by anonymousstar
        What I wanted to know is how to change the value of the hidden field so that I can see what the user has selected. 1,2 is the co-ordinates of the cell. row 1, cell 2 and so on. when they select that cell I would like to concantenate selected onto the 1,2 string. I had this example before but when I went to view the source I did not see a change. Is this because I need to use cookies?
        To concatenate, use += , e.g. document.getEle mentById("r1w2b ").value += " selected".

        You won't see a change if you view the source. Inspect the element using, for example, the Firebug extension on Firefox.

        Comment

        • anonymousstar
          New Member
          • Mar 2008
          • 15

          #5
          Originally posted by acoder
          To concatenate, use += , e.g. document.getEle mentById("r1w2b ").value += " selected".

          You won't see a change if you view the source. Inspect the element using, for example, the Firebug extension on Firefox.

          Fantastic
          Thank you for your help. It really is appreciated.

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            You're welcome. Glad it helped.

            Comment

            Working...