Solved

need code:how to make a seat plan by javascript

Posted on 2000-04-13
9
724 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
ID: 2712830
define seatplan
0
 
LVL 2

Author Comment

by:hpchong7
ID: 2712905
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
ID: 2713269
for both IE and Netscape or just IE? If it's just IE I can make it really fast...well, half an hour
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
LVL 2

Author Comment

by:hpchong7
ID: 2714374
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
 
LVL 22

Expert Comment

by:CJ_S
ID: 2714981
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
ID: 2715612
Adjusted points from 10 to 25
0
 
LVL 2

Author Comment

by:hpchong7
ID: 2715613
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
ID: 2717037
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
ID: 2730132
thank you very much!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Underline in nav for the page that you are currently on. 1 22
Html Table looping 4 26
html input 8 43
Alert after MVC form submitted 1 22
This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
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…

830 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