SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: onClick

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Jan 2003
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exclamation onClick

    Hi Everbody,
    I'm making an online reservation. User can choose empty seats to make reservation. Empty seats are green.gif and when user clicks on it, it changes yellow.gif and if user gives up that seats and wanna choose any others, he/she clicks on previously seats and they would be green again and choose anothers. I use php+apache+mysql trio. How can I find reserved seats to save them into database. Bye.

  2. #2
    SitePoint Guru dale_burrell's Avatar
    Join Date
    Aug 2002
    Location
    Wellington, New Zealand
    Posts
    861
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I can think of a couple of solutions...

    1) Have a hidden input field which you add the reserved seat numbers to using the onClick handler of the image and when the form is submitted you will receive this information at the server.

    2) Store the seat numbers in a local (JavaScript) variable and then when the user presses submit, use the onSubmit function to build a URL to load to using the seat numbers are arguments, e.g.
    Code:
    location.href=store.php?seats=1+3+4;
    form.onsubmit=null;
    If you aren't living life on the edge
    - you're taking up too much space
    Creative Dreaming Ltd / Ask The Local / Amanzi Travel

  3. #3
    SitePoint Member
    Join Date
    Jan 2003
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this :

    Code:
    <script language="JavaScript">
    function toggleValue()
    {
       if(this.src=="green.gif")
       {
          this.src="yellow.gif";
          document.form1.reserve.value="1";
       }
       else
       {
          this.src="green.gif";
          document.form1.reserve.value="0";
       }
    }
    </script>
    
    <form name="form1" action="yourPHPfile.php">
    <img src="green.gif" onClick="toggleValue()">
    <input type="hidden" name="reserve" value="0">
    </form>


Bookmarks

Posting Permissions

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