hi
i need a little help pls.
im trying to write a Black Jack game with JS(home assignement)
can someone pls tell me why when i click on the img, the number 4000 doesnt change?
here is the code

<html>
<head>
<title>Black Jack</title>
<Script Language="JavaScript">
function hit(f)
{
 
 var i=3900;
  f.money.value = i;
}
</Script>

</head>

<body>
<form name="bj">
<table width="100%" height="100%" border="1">

  <tr align="center" height="25%">
    <td>Money:<input name="money" type="text" value="4000" size="4" /> $</td>
    <td>&nbsp;</td>
    <th>&nbsp;</td>
    <td></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td></td>
  </tr>
  <tr align="center" height="50">
    <td><input type="image" src="c255.jpg"  name="c25" onClick="hit(this.form)"/></td>
    <td><input type="image" src="c50.jpg"  name="c50"/></td>
    <td><input type="image" src="c100.jpg"  name="c100"/></td>
  	<td><input type="submit"  value="Hit Me" onClick="hit(this.form)"/></td>
    <td><input type="submit"  value="Hold" /></td>
    <td><input type="submit" value="Deal Again"  /></td>
  </tr>

</table>
</form>



</body>
</html>

thanks in advance!

Try this instead,

function hit( f ) {
var i = 3900;
f.vaule = i;
}

you can then reference it with your attached events' doing this format: <img src="image1.jpg" onclick="hit( this );" alt="" />

it wont work because its not what i want to do...
it for somereason doing "Back" the the previous page...
i dont know why

Sorry i've slipped over there, kinda rush back to my work.

I meant:

<input type="image" src="c225.jpg" name="c25" onclick="hit( bj );" />

Every time you call the function you are resetting i. put i outside of the function to keep the value and have in increment.
try this:

var i = 3900;
function hit( f ) {
     f.vaule = i;
}

Your code is making the change....but the Hit Me button ALSO is a submit button which is causing the page to reload...erasing the change. Change the type on Hit Me to a plain old button instead of a submit and you'll see your function working just fine.

Your Javascript code is OK.
Change your button type from 'submit' to 'button' for the Hit Me button:

<input type="button"  value="Hit Me" onClick="hit(this.form)"/>

.
Pressing a 'submit' button will cause the page being reloaded.

first of all, thank you all for your replies!
hengzhe you are the only one who got me close.
changing it from "submit" to "button" did fix the problem for the "hit me" button, but not for the img button...
when i press it, it still reload my page to the default data...
do u know how i can fix this problem with the picture button?

Actually, an 'image' is just another 'submit' button.
You can change it to 'button' too.And set the button's background image(using css: background-image) to corresponding images.

you gave me an intresting point a view.
the problem now, that when i write this code:

style="background-image:url(c255.jpg)"

it doesnt show me the whole picture...
do u know how to fix it?

This question has already been answered. Start a new discussion instead.