/    Sign up×
Community /Pin to ProfileBookmark

Help with events

Hello guys:

I have two questions. I’m programming an online game with PHP and I need two things:

a) Let’s suppose that var x has value 3. Then, with clicking in a link, x should increment by 1 and it should be showed instead of 3.

Example (this represents the screen):


———————–

Value: 3

Click here to increment
———————–

–after click–>


———————–

Value: 4

Click here to increment
———————–

So, how would yo do it?

b) I need that when pointing in a link (so, onHover event?) the info in a frame is changed. So, if we have links a and b, when pointing at link a the text in the other frame should be ‘aaaaa’ and when pointing at b the text should be ‘bbbbb’ (but without reloading the frame).

As you see, I’m completely ignorant in Javascript. I hope you help me ?

Greetings from Girona, Spain.

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@ArnauDuranauthorApr 25.2006 — Please?
Copy linkTweet thisAlerts:
@vwphillipsApr 25.2006 — [CODE]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>
<title></title>
<script language="JavaScript" type="text/javascript">
<!--
var Value=0;

function Cng(add){
Value+=add;
alert(Value);
}


function Cng2(v,add){
window[v]+=add;
alert(Value);
}

//-->
</script>
</head>

<body>

<span onclick="Cng(+1);" >Click here to increment</span>
<br>
<br>
<span onclick="Cng(-1);" >Click here to increment</span>
<br>
<br>
<span onclick="Cng2('Value',+1);" >Click here to increment</span>
<br>
<br>
<span onclick="Cng2('Value',-1);" >Click here to increment<br</span>
</body>

</html>[/CODE]
Copy linkTweet thisAlerts:
@vwphillipsApr 25.2006 — [CODE]<html>
<head>
<meta name="description" content="Divides the pages horizontally in three frames.">
<title>No title</title>
</head>

<frameset id="top1" rows="1*, 1*">
<frame src="a_1.htm" name="f1" scrolling="auto" marginwidth="10" marginheight="14">
<frame src="a_2.htm" name="f2" scrolling="auto" marginwidth="10" marginheight="14">
<noframes>
<body bgcolor="white" text="black" link="blue" vlink="purple" alink="red">
&quot;&gt;
<p>You need a browser that supports frame to veiw this page.</p>
</body>
</noframes>
</frameset>
</html>
[/CODE]



[CODE]
<html>
<head>
<title>f1</title>
</head>

<body>

<span onclick="Send('Some Text','f2','fred');" >Link</span>
<script language="JavaScript">

<!--
function Send(txt,frm,id){
window.top[frm].document.getElementById(id).innerHTML=txt;
}
//-->

</script>


</body>
</html>[/CODE]




[CODE]<html>
<head>
<title>f2</title>
</head>

<body>

<div id="fred" >fred</div>


</body>
</html>[/CODE]
Copy linkTweet thisAlerts:
@ArnauDuranauthorApr 25.2006 — Many many thanks. Works perfectly.
×

Success!

Help @ArnauDuran spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...