473,395 Members | 1,473 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Beginner Needing Help

Hi All,
below is come code I'm writing for an assignment, and I'm stuck.
What I want to happen:
page load,
user click on money
money = bank
bank is displayed in a text box

I can get the bank to display the initial value of 0, but not the bank value
after the user input.

Cheers..

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>:: Tafe - Roll a Dice ::</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<!-- Casion Emulator - Matthew Howes -->

<script language="JavaScript" type="text/javascript">
<!-- Hide me from old browsers

// Gets bg colour based on time
time = new Date()
if (time.getHours() <= 12) {
document.bgColor = "CC0000" }
else {
document.bgColor = "339900"
}

// Casion Images
function pic(){
pic_array=new Array()
pic_array[1]="images/pic01.gif"
pic_array[2]="images/pic02.gif"
pic_array[3]="images/pic03.gif"
pic_array[4]="images/pic04.gif"
pic_array[5]="images/pic05.gif"
pic_array[6]="images/pic06.gif"

picnum=Math.floor(Math.random()*pic_array.length)
if (picnum==0)
picnum=1
document.write('<center><img src="'+pic_array[picnum]+'"
border=0></center><br>')
}
pic()

// Game starts here

var bank = 0
var money_in = 0
var dep_clickcount = 0
var pick_clickcount = 0
var roll_clickcount = 0

// Prompt for deposit
function deposit(money_in) {

if ( dep_clickcount == 0 ) {
alert( "You Deposited $" + money_in )
bank = money_in
dep_clickcount++
}
else { alert("You can only make one deposit, hit 'refresh' if you wish to
change your deposit")
}
}

// end hide -->
</script>

</head>

<body link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF"
onload="javascript:document.bal.Balance.value = bank;">
<br>
Click the amout you wish to deposit
<br>
<IMG onmouseover="window.status='$500'" onclick="deposit(500)"
onmouseout="window.status='';return true" height=75 src="images/0500.gif"
width=200>
<IMG onmouseover="window.status='$600'" onclick="deposit(600)"
onmouseout="window.status='';return true" height=75 src="images/0600.gif"
width=200>
<IMG onmouseover="window.status='$700'" onclick="deposit(700)"
onmouseout="window.status='';return true" height=75 src="images/0700.gif"
width=200><br>
<IMG onmouseover="window.status='$800'" onclick="deposit(800)"
onmouseout="window.status='';return true" height=75 src="images/0800.gif"
width=200>
<IMG onmouseover="window.status='$900'" onclick="deposit(900)"
onmouseout="window.status='';return true" height=75 src="images/0900.gif"
width=200>
<IMG onmouseover="window.status='$1000'" onclick="deposit(1000)"
onmouseout="window.status='';return true" height=75 src="images/1000.gif"
width=200>
<br>
<br>
<form name="bal">
<input name="Balance" type="text" value="" size="8" maxlength="8">
</form>
<br>
<p align="center"><a href="casino.html"><font size="5" face="Comic Sans
MS">Return to casino</font></a></p>
</body>
</html>

--
::::x::::

"Me fail English, that's unpossible"
Jul 20 '05 #1
1 1592
On Thu, 04 Sep 2003 14:39:38 +1000, ::::x:::: wrote:
Hi All,
below is come code I'm writing for an assignment, and I'm stuck.
What I want to happen:
page load,
user click on money
money = bank
bank is displayed in a text box

I can get the bank to display the initial value of 0, but not the bank value
after the user input.

Cheers..

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>:: Tafe - Roll a Dice ::</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<!-- Casion Emulator - Matthew Howes -->

<script language="JavaScript" type="text/javascript">
<!-- Hide me from old browsers

// Gets bg colour based on time
time = new Date()
if (time.getHours() <= 12) {
document.bgColor = "CC0000" }
else {
document.bgColor = "339900"
}

// Casion Images
function pic(){
pic_array=new Array()
pic_array[1]="images/pic01.gif"
pic_array[2]="images/pic02.gif"
pic_array[3]="images/pic03.gif"
pic_array[4]="images/pic04.gif"
pic_array[5]="images/pic05.gif"
pic_array[6]="images/pic06.gif"

picnum=Math.floor(Math.random()*pic_array.length)
if (picnum==0)
picnum=1
document.write('<center><img src="'+pic_array[picnum]+'"
border=0></center><br>')
}
pic()

// Game starts here

var bank = 0
var money_in = 0
var dep_clickcount = 0
var pick_clickcount = 0
var roll_clickcount = 0

// Prompt for deposit
function deposit(money_in) {

if ( dep_clickcount == 0 ) {
alert( "You Deposited $" + money_in )
bank = money_in
dep_clickcount++
}
else { alert("You can only make one deposit, hit 'refresh' if you wish to
change your deposit")
}
}

// end hide -->
</script>

</head>

<body link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF"
onload="javascript:document.bal.Balance.value = bank;">
<br>
Click the amout you wish to deposit
<br>
<IMG onmouseover="window.status='$500'" onclick="deposit(500)"
onmouseout="window.status='';return true" height=75 src="images/0500.gif"
width=200>
<IMG onmouseover="window.status='$600'" onclick="deposit(600)"
onmouseout="window.status='';return true" height=75 src="images/0600.gif"
width=200>
<IMG onmouseover="window.status='$700'" onclick="deposit(700)"
onmouseout="window.status='';return true" height=75 src="images/0700.gif"
width=200><br>
<IMG onmouseover="window.status='$800'" onclick="deposit(800)"
onmouseout="window.status='';return true" height=75 src="images/0800.gif"
width=200>
<IMG onmouseover="window.status='$900'" onclick="deposit(900)"
onmouseout="window.status='';return true" height=75 src="images/0900.gif"
width=200>
<IMG onmouseover="window.status='$1000'" onclick="deposit(1000)"
onmouseout="window.status='';return true" height=75 src="images/1000.gif"
width=200>
<br>
<br>
<form name="bal">
<input name="Balance" type="text" value="" size="8" maxlength="8">
</form>
<br>
<p align="center"><a href="casino.html"><font size="5" face="Comic Sans
MS">Return to casino</font></a></p>
</body>
</html>


Hi

It should read like this, then the alert will display the correct value

document.write("<center><img src=" + pic_array[picnum] +
"border=0></center><br>")
*********** all on one line ************

Also the alert is not showing the direct value of bank, but the value of
"money_in" don't know if this will make a difference later in the program.

Have fun
DaveG
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Grrrbau | last post by:
I'm a beginner. I'm looking for a good C++ book. Someone told me about Lafore's "Object-Oriented Programming in C++". What do you think? Grrrbau
14
by: japin0 | last post by:
Hi, I am a absolute beginner in ASP ..I do have a bit of exposure to .VBS and other scripting languages. I need your guidance, where do I start? I had been to MS website Quick start guide but it...
5
by: Jozef | last post by:
Hello, I have done a little "old" ASP work along with some javascript. I'm currently getting into ASP.net and would like to step up my game overall with regard to Web Development. I was...
1
by: hl | last post by:
Hi, I'm a beginner and need a little help with getting data back from a web service. I am using VB.Net and have added a web reference to a Wsdl that was provided to me. My reference.vb file...
7
by: tsivaraman | last post by:
Hi I am a PHP ,MySQL newbie.Just finished learning the basics of PHP programming and MySQL interaction.Can anyone suggest some project topics that will help me gain hands-on experience in...
4
by: chris19845 | last post by:
Hi there, I am a complete beginner so apologies if I make not a lot of sense. What I am trying to do is write a simple class, it has a class array variable named test of type String, ie private...
13
by: Jack B | last post by:
I'm using Access 2002 to create a database for a small opera company that my wife is involved in, and I'm more than a bit rusty because I haven't created a new Access database since about 1999. ...
6
by: robtyketto | last post by:
Greetings, Im a newbie to JSP/Javascript (unfortunalley). However I found enough example to create code that connects to my access db and populates two combo boxes. The selection of the...
10
by: hamza612 | last post by:
I want to start learning how to program. But I dont know where to start. From what I've heard so far c++ is not a good lang. to learn as a beginner because its very complicated compared to others...
22
by: ddg_linux | last post by:
I have been reading about and doing a lot of php code examples from books but now I find myself wanting to do something practical with some of the skills that I have learned. I am a beginner php...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.