Solved

need code:how to make a seat plan by javascript

Posted on 2000-04-13
9
711 Views
Last Modified: 2012-05-04
Dear all,

    Do anyone have the sample code how to make a seat plan by javascript?Thanks!
0
Comment
Question by:hpchong7
  • 5
  • 4
9 Comments
 
LVL 22

Expert Comment

by:CJ_S
Comment Utility
define seatplan
0
 
LVL 2

Author Comment

by:hpchong7
Comment Utility
Seat Plan:
A  9*9 square.When mouse enter one square,its color would be highlighted(I know using onmouseover)Then After user click on it,A char  "*" would be display on the square and the seat number can be obtained (for update the database)and other user can no longer choose it.

Thanks!
0
 
LVL 22

Expert Comment

by:CJ_S
Comment Utility
for both IE and Netscape or just IE? If it's just IE I can make it really fast...well, half an hour
0
 
LVL 2

Author Comment

by:hpchong7
Comment Utility
It would be better for both IE and Netscape.Anyway,if you know of code of just IE,that's also okay.May you teach me how to make for Netscape?What's the difficulties?If I raised to 20 marks,would you also help me to make the version for Netscape?
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 22

Expert Comment

by:CJ_S
Comment Utility
10 points isn't much, 20 points isn't much either, but that doesn't matter. I'm at work right now, and to make it right now wouldn't be too nice for my boss.....I hope you can wait untill I'm at home (9 hours from now)
0
 
LVL 2

Author Comment

by:hpchong7
Comment Utility
Adjusted points from 10 to 25
0
 
LVL 2

Author Comment

by:hpchong7
Comment Utility
Thank you very very very very very much!You save me!I would wait for you!
0
 
LVL 22

Accepted Solution

by:
CJ_S earned 25 total points
Comment Utility
Hi there again. I didn't feel like writing 9 * 9 the same thing, so I leave that to you.

But the following is the code:

<script language=javascript>
<!--
    var SeatTaken = new Array();
    for(x=0;x<9*9;x++)
    {
         SeatTaken[x] = 0;
    }
    var Images = new Array();
    Images[0] = new Image();
    Images[0].src = "PIXEL.jpg";
    Images[1] = new Image();
    Images[1].src = "PIXEL2.jpg";
    Images[2] = new Image();
    Images[2].src = "X.jpg";

    function MouseOver(Obj, nr)
    {
       if(SeatTaken[nr]==0)
          Obj.src = Images[0].src;
    }

    function MouseOut(Obj, nr)
    {
        if(SeatTaken[nr]==0)
           Obj.src = Images[1].src;
    }

    function Click(Obj, nr)
    {
       if(SeatTaken[nr]==0)
       {
           Obj.src = Images[2].src;
           SeatTaken[nr]=1;
       }
       else
           alert("Place has already been taken.")
    }

//-->
</script>

  <td>
       <a onmouseover="MouseOver(document.x2y1, 2)" onmouseout="MouseOut(document.x2y1, 2)" onclick="Click(document.x2y1, 2)"><img name=x2y1 src="pixel2.jpg" width=30 height=30></a>
  </td>

Some explanation.

I made a table, inside the table you have 9 rows and 9 columns.
Inside each cell you put an image to start with. You give the image a name (I thought about using x1y1, until x9y9). In the <A> tag you use the onmouseover tag with the document.x1y1 thing, AND an additional number of the place (used for reference for the Array).

The 3 images used:
pixel.jpg was a white one, wasn't showing on the white background (you casn also use a transparent gif).
pixel2.jpg was a black one to indicate over which cell / image the user was hovering.
x.jpg was a picture with a BIG X on it. To let the user specify the place he wants to take.

You should write the initialization code yourself, just like the updatestatement for tha database when the user has selected a cell.

Good luck
0
 
LVL 2

Author Comment

by:hpchong7
Comment Utility
thank you very much!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now