Solved

need code:how to make a seat plan by javascript

Posted on 2000-04-13
9
720 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…

822 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