Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Need help with a CGI game PLEASE!!

Need help with a CGI game PLEASE!!

Need help with a CGI game PLEASE!!

I truly hope someone can help me with this!

I'm making a simple playing card game, setting up the database is simple, the script is simple but there is one thing that baffles me....

Here's the card layout

Once the person picks their court card(s) and clicks the button - the card game will be laid out like this...
*****card 1*******
*****card 2*******
*****card 3*******
*****card 4*******
*****card 5*******
*****card 6*******
*****card 7*******
*****card 8*******
*****card 9*******
*****card 10******

Here's is what's racking my brain and baffles me - I want to keep 'one card' appearing randomly in one of these 10 positions per ONCLICK?

Here's an example...
*****card 1 position*******King of Hearts******
*****card 2 position*******Ace of Spade******
*****card 3 position*******Two of Hearts*****
*****card 4 position*******Three of Diamonds*
*****card 5 position*******Five of Clubs*****
*****card 6 position*******Nine of Hearts****
*****card 7 position*******Eight of Clubs****
*****card 8 position*******Seven of Spades***
*****card 9 position*******Four of Clubs*****
*****card 10 position******Ten of Diamonds***

The King of Hearts is the card I want to keep repeating randomly in one of the 10 positions.

Here's more detail on this - Lets say I clicked the button and now the King of Hearts is in position 9 instead of 1. Next time the King of Hearts is in position 3 instead of 9 however, all the other cards listed above are being executed by a cgi database at random, appearing in one of those 10 position WITH the King of Hearts. (K-of-H will always been in one of those position each time the person clicks the button.)

I hope I explained this well without confusion.

So I was wondering can I use random javascript for the King of Hearts and have the ONCLICK execute the cgi database for ace-ten? Can this be done? If so, can someone explain how I can do this or provide a simple script source...I'll be forever thankful!

Or is there a simple way to execute two databases on one ()ONCLICK? If so, can someone please explain how?

If anyone has any questions or needs more info from me please let me know.

Thanks in advance for your help!

Just in case- here is a copy of the cgi script that executes the database...

<FORM NAME="CardForm" ACTION="/cgi/card.cgi"

<SELECT NAME="spreadpath" SIZE="1">



<SELECT NAME="deckpath" SIZE="1">

VALUE="../cards/databases/cards.cgi">Card Location</OPTION>

VALUE="Get Cards"
ONCLICK="var forever=new Date('October 17, 2030 03:24:00')var forever=new Date('October 17, 2030 03:24:00');setCookie('spreadpath', document.cardForm.spreadpath.value , forever , '', '', '');setCookie('deckpath', document.cardForm.deckpath.value , forever , '', '', '');"></P></FORM>

document.cardForm.spreadpath.value = getCookie('spreadpath') || '../card/layout/10card.html';
document.cardForm.deckpath.value = getCookie('deckpath') || '../cards/databases/cards.cgi';


RE: Need help with a CGI game PLEASE!!


The code you posted above isn't CGI although the post action is card.cgi (but you haven't provided any code for this). Looks like you are trying to build your game using javascript therefore the javascript forum would have probably been more useful.

I'm not sure if I quite follow however you discussed that you would like to run your "cgi database" using a javascript onClick event. This would require using an AJAX XML Http Request (http://www.w3schools.com/ajax/ajax_xmlhttprequest.asp). This allows you to use the client side language (javascript) to access and return data from a server side script (CGI).

I apologise if this isn't what you are trying to achieve,


RE: Need help with a CGI game PLEASE!!


I hope I explained this well without confusion
Nope, I don't have a clue what you're trying to do.

However, it is clear that you don't understand the distinction between server-side and client-side code. CGI is a server-side approach - you submit a set of data to the script, and it returns a new page as a result.

Onclick is a client-side event - it triggers a bit of javascript that runs locally on your machine. It is possible to combine the two approaches - via AJAX, for example - but you need to know the basics of what's happening where.

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close