/    Sign up×
Community /Pin to ProfileBookmark

Changing picture after OK has been pressed?

I have another question – it has to do with my rollovers. I have the webpage set up so that when the mouse rolls over a black image, it turns orange. Now, there are four black images (they’re actually answers to questions). The black images (a.jpg, b.jpg, c.jpg, and d.jpg) are the original images. Now, when the user rolls over, it switches to aon.jpg, bon.jpg, conn.jpg, and don.jpg. After the mouse leaves, it turns black again. I have the webpage set up so that if one of the four rollovers is clicked, a confirm window will popup, with OK and Cancel. If the user clicks OK, the page will run on (I have it delay for 6 seconds, then go to the new page).

My question is, how can I get it so that after the user clicks “OK” in the confirm window, the rollover image will change to aon.jpg, or bon.jpg, etc, while the page is going through its 6 second delay? (This means the image will go orange). Is there a code that I insert in the confirm window, or the rollover? Would it be onclick = ?

I have a weird setup, and the code for the confirm window is actually near the top of the page, not on each rollover. It’s a pretty complicated setup. I’ll post the codes, and hopefully somebody can help me out. Thanks! ?

<HTML>
<HEAD>
<TITLE>Who Wants To Be A Millionaire
</TITLE>
<SCRIPT TYPE=”text/javascript”>
<!–
// copyright 1999 Idocs, Inc. [url]http://www.idocs.com/tags/[/url]
// Distribute this script freely, but please keep this
// notice with the code.

var rollOverArr=new Array();
function setrollover(OverImgSrc,pageImageName)
{
if (! document.images)return;
if (pageImageName == null)
pageImageName = document.images[document.images.length-1].name;
rollOverArr[pageImageName]=new Object;
rollOverArr[pageImageName].overImg = new Image;
rollOverArr[pageImageName].overImg.src=OverImgSrc;
}

function rollover(pageImageName)
{
if (! document.images)return;
if (! rollOverArr[pageImageName])return;
if (! rollOverArr[pageImageName].outImg)
{
rollOverArr[pageImageName].outImg = new Image;
rollOverArr[pageImageName].outImg.src = document.images[pageImageName].src;
}
document.images[pageImageName].src=rollOverArr[pageImageName].overImg.src;
}

function rollout(pageImageName)
{
if (! document.images)return;
if (! rollOverArr[pageImageName])return;
document.images[pageImageName].src=rollOverArr[pageImageName].outImg.src;
}
//–>
</SCRIPT>
<script>
history.forward()
</script>
<SCRIPT LANGUAGE=”JavaScript”>
<!– Begin
var hint = 0;
function Hint () {
if (hint >= 0) {
alert(“This is not a short word, but it’s not necessarily a long word, either.”)
}
}
// End –>
</SCRIPT>
[COLOR=Red]<Script Language=JavaScript>

var delayCount = 0;

function delayExit(){

if (delayCount < 6 )
{
delayCount++;
setTimeout(“delayExit()”,1150);
}
else {window.location.replace(‘Allinfo/50000wr.html’)}
}

function playClip(){

document.getElementById(‘bgWav’).src = “Allinfo/50final.mp3”;
delayExit();
}

function exitPlay(){

if (confirm(‘Is that your final answer?’))
{
playClip();
}
}

</Script><Script Language=JavaScript>

var delayCount = 0;

function delayExit2(){

if (delayCount < 6 )
{
delayCount++;
setTimeout(“delayExit2()”,1150);
}
else {window.location.replace(‘Allinfo/50000r.html’)}
}

function playClip2(){

document.getElementById(‘bgWav’).src = “Allinfo/50final.mp3”;
delayExit2();
}

function exitPlay2(){

if (confirm(‘Is that your final answer?’))
{
playClip2();
}
}

</Script>[/COLOR]</HEAD>
<BgSound id=’bgWav’ Loop=1 Volume=”+500″ Src=”Allinfo/50000.mp3″>
<BODY bgcolor = “black” alink = “black” vlink = “black” link = “black” onload=”alert(‘ATTENTION – PLEASE READ!nn Upon clicking Final Answer in the following round, the page will appearn to do nothing for eight seconds. This is not a malfunction.’)”>
<CENTER>
<TABLE align = “left”>
<TR>
<TD><CENTER><IMG SRC = “Allinfo/Millionaire.jpg”></CENTER></TD>
</TR>
</TABLE>
</CENTER>
<TABLE align = “right”>
<TR>
<TD><CENTER>
<BR>
<FORM>
<INPUT
TYPE=”button” ONCLICK=”Hint()” VALUE=”Free Hint”></FORM>
</CENTER>
</TD>
</TR>
<TR>
<TD><IMG SRC = “Allinfo/50000Total.jpg”>
</TD>
</TR>
</TABLE>
<BR>
<P>
<BR>
<P>
<BR>
<P>
<BR>
<P>
<BR>
<P>
<BR>
<P>
<BR>
<P>
<BR>
<BR><TABLE align = “left”>
<TR>
<TD colspan = “2”>
<IMG SRC = “Allinfo/50000money.jpg”>
</TD>
</TR>
<TR>
<TD colspan = “2”>
<IMG SRC = “50000info/Question50000.jpg”>
</TD>
</TR>
<TR>
<TD>
[COLOR=Red]<A

onMouseOver = “rollover(‘A’); window.status=’A’;return true”
onMouseOut = “rollout(‘A’)”><IMG
SRC=”50000info/A.jpg” onclick=”exitPlay()”
NAME=”A”
ALT=”A”></A>
<SCRIPT TYPE=”text/javascript”>
<!–
setrollover(‘50000info/Aon.jpg’);
//–>
</SCRIPT>
</TD>
<TD>
<A

onMouseOver = “rollover(‘B’); window.status=’B’;return true”
onMouseOut = “rollout(‘B’)”
><IMG
SRC=”50000info/B.jpg” onclick=”exitPlay()”
NAME=”B”
ALT=”B”
></A>

<SCRIPT TYPE=”text/javascript”>
<!–
setrollover(‘50000info/Bon.jpg’);
//–>
</SCRIPT>
</TD>
</TR>
<TR>
<TD>
<A

onMouseOver = “rollover(‘C’); window.status=’C’;return true”
onMouseOut = “rollout(‘C’)”
><IMG
SRC=”50000info/C.jpg” onclick=”exitPlay()”
NAME=”C”
ALT=”C”
></A>

<SCRIPT TYPE=”text/javascript”>
<!–
setrollover(‘50000info/Conn.jpg’);
//–>
</SCRIPT>
</TD>
<TD>

<A

onMouseOver = “rollover(‘D’); window.status=’D’;return true”
onMouseOut = “rollout(‘D’)”
><IMG
SRC=”50000info/D.jpg” onclick=”exitPlay2()”
NAME=”D”
ALT=”D”
></A>

<SCRIPT TYPE=”text/javascript”>
<!–
setrollover(‘50000info/Don.jpg’);
//–>
</SCRIPT>[/COLOR]</TD>
</TR>
<TR>
<TD colspan = 2>
<A
HREF=”Allinfo/50000walk.html” onCLick=”return confirm(‘Are you sure you want to walk?’)”
onMouseOver = “rollover(‘Walk’); window.status=’Walk’;return true”
onMouseOut = “rollout(‘Walk’)”
><IMG
SRC=”Allinfo/Run.jpg”
NAME=”Walk”
ALT=”Walk”
></A>
<SCRIPT TYPE=”text/javascript”>
<!–
setrollover(‘Allinfo/Runon.bmp’);
//–>
</SCRIPT>
</TD>
</TR>
</TABLE>

to post a comment
HTML

14 Comments(s)

Copy linkTweet thisAlerts:
@BonRougeApr 01.2005 — OK, now I'm no expert, but you could try this...

Add this to the functions you have in the head (before the final '</script>') :[CODE]function exit() {
var option=['A','B','C','D'];
for(var i=0; i<option.length; i++)
{
rollover(option[i])
}
confirm('Are you sure you want to walk?')
}
[/CODE]

and change this : [CODE]<A
HREF="Allinfo/50000walk.html" onCLick="return confirm('Are you sure you want to walk?')"
onMouseOver = "rollover('Walk'); window.status='Walk';return true"
onMouseOut = "rollout('Walk')"
>[/CODE]
to this :[CODE]<a href="Allinfo/50000walk.html" onclick="exit()"
onmouseOver = "rollover('Walk'); window.status='Walk';return true"
onmouseOut = "rollout('Walk')"
>[/CODE]


I hope this helps. If you have problems, let me know and I'll see what I can do.
Copy linkTweet thisAlerts:
@tburtonauthorApr 02.2005 — I think it might work, but you didn't do it for the right section. I have the page like this:

A------------------------B

c------------------------D

-------Walk---------------

I want it so that when you click A, for example, it will hold it on orange after OK has been clicked. When I click D on the example you provided, it goes to the Walk button - it's very strange. Could you try redoing it? I noticed that the first code you told me to add had "Walk with the money" in it, but I actually want the one with "Is that your final answer?" Hopefully this makes sense? Thanks for your help!
Copy linkTweet thisAlerts:
@BonRougeApr 02.2005 — I guess I misunderstood... I'm busy today - I'll get back to this soon.
Copy linkTweet thisAlerts:
@_lt_Eddie_gt_Apr 02.2005 — The very first thing I would do is use CSS a:hover to give the rollover effect. That would eliminate about 2/3 of the code you have there. It seems terribly over engineered which usually spells future reliability problems. To answer your question, I would use img.src within the alert code to amend the images.

If I completely misunderstood the problem though, say so. It's easier to deal with tricky pages such as yours when they're published online. Do you have a link to it?
Copy linkTweet thisAlerts:
@BonRougeApr 02.2005 — I just came back to say the same thing - can you post a link to the page?
Copy linkTweet thisAlerts:
@BonRougeApr 02.2005 — Hi, so yeah... I can see what you meant now, but I'm tired and I don't have time to try to fix it all. One problem is what Eddie mentioned - you're using javascript where it isn't necessary - for rollovers, you can reliably use css - [URL=http://bonrouge.com/br.php?page=rollover2]here's an example[/URL].

Besides that, I think you need to learn more css and get away from tables - read the article in my sig and try [URL=http://www.w3.org/TR/CSS21/indexlist.html]W3Schools[/URL].

Still, if you give us a link to your page and you want to keep it as it is - with the tables and whatever - I'll see what I can do...
Copy linkTweet thisAlerts:
@tburtonauthorApr 06.2005 — Thanks for all your help guys. I do have the page online, and I'll give you a link, so you can see if you can figure it out. Save the whole webpage and try fooling around with the codes, and hopefully you'll be able to solve the problem (I really don't know what to do...?).

Just in case you've forgotten, when you go the page, you click on your answer (A, B, C, or D) and when you do a confirm window pops up asking if you're sure of your answer. I want it so that you click OK, and the rollover immediately locks in the orange/aon.jpg picture. Here is the website, and thanks for all your help!

http://aths.rrdsb.com/Millionaire/$100000v3x2r2q12.html
Copy linkTweet thisAlerts:
@BonRougeApr 06.2005 — Hey tburton,

[URL=http://bonrouge.com/test/millionaire.htm]I hope you like this[/URL] because to be honest, I'm pretty happy with it.

I've changed most of the page - removed a lot of the javascript and replaced it with css rollovers and got rid of your tables. It's a much cleaner page. As I said, I hope you like it and are able to use it...

Let me know what you think.
Copy linkTweet thisAlerts:
@tburtonauthorApr 06.2005 — Thanks for fixing up the page - the only problem is, I'm not really sure how it works.... I have many different pages, because there are many different questions. I guess if I put it on my page, I'll have to figure out how everything works so that I can change my other pages to fit it. I'm just not sure if it's worth all the extra time and effort that I will have to put in to change all my other pages... ?

There are a few problems:

  • 1. When I click final answer, part of the total picture on the right disappears.

  • 2. At the bottom, you can see javascript:exitplay, and you can see which of the answers is correct. Could you find a way to hide this? I tried using window.status on my old pages, but you could still see the words below if you moved your mouse rapidly over the picture. Also, when I click, it shows the code again.

  • 3. Could you get it so that when you click your answer, it asks if that is final in a confirm window (like I have in my original page). Also, could you have it so that it glows orange?


  • Thanks for all your time and effort - I'll see, maybe I will use it, it's just that I would have to put in a lot of work, and it might just be easier if you could find a way to make it glow orange onclick=, without changing the original page. Your page is definitely better codewise, but I have so many pages, I would have to work a long time to fix them all up.
    Copy linkTweet thisAlerts:
    @tburtonauthorApr 06.2005 — Oh, I just noticed that it does glow orange onclick. I think you forgot to change exitplay(2), because when I click that one it stays the same. Also, when I click the answer, could you make it so that the purple border around the image disappears?
    Copy linkTweet thisAlerts:
    @BonRougeApr 06.2005 — OK, I've fixed a few things - see what you think now.

    I can see it might take a while to change your other files, but this was the only way I could see to do it. I wanted to fix the image to an 'on' state with a javascript onclick event, but you had a javascript mouseout thing going on so which would cancel out anything I did there. Partly for this reason, I wanted to use css for the image swaps...

    A quick explanation :

    The background image of the li changes on hover. There's an image in the link which is set to 'display:none'. It's the same as the onhover image. Onclick it becomes 'display:block' so it doesn't change because you can't see the background anymore.

    Erm... so yeah, like I said, I can see it might be a hassle to change your other files, but it might be the best thing in the long run...
    Copy linkTweet thisAlerts:
    @tburtonauthorApr 06.2005 — Okay, well it's better now, but I think you changed something to the exitplay() because it doesn't make the final answer noise when I click the answer I want. Also, the confirm window doesn't seem to be working correctly on your page. When I click CANCEL on B, it goes to the next page anyway, and also, it shuts off the music. I would like it to keep the music playing if CANCEL is pressed - you must have changed something there. Other than that, it looks pretty good! ?

    There has to be a way to do the code without having to change everything. I was looking around and I found this code:

    <TD>

    <A

    onMouseOver = "rollover('A'); window.status='A';return true"

    onMouseOut = "rollout('A')"><IMG

    SRC="50000info/A.jpg" onclick="exitPlay()" NAME = "a" ONMOUSEDOWN="document.images['a'].src='50000info/aon.jpg'"

    NAME="A"

    ALT="A"></A>

    <SCRIPT TYPE="text/javascript">

    <!--

    setrollover('50000info/Aon.jpg');

    //-->

    </SCRIPT>

    </TD>

    The ONMOUSEDOWN code will do exactly what I want, except for one tiny problem: after you click it, it won't go away (if the user clicks CANCEL, their first answer will remain highlighted.) It would be A LOT easier if I could somehow just use this code in my website. Your webpage is a lot more efficient and it will probably work better, but if I wanted to save time, this would be the way to go.

    What do you think I should do? There has to be a code that I could use this with. Do you think there's a way to put it with the confirm window code, or something like that? Or maybe I could add something into that code, that will turn it off if Cancel is clicked....
    Copy linkTweet thisAlerts:
    @tburtonauthorApr 06.2005 — What if we used a different confirm window code? Like the one below:

    <SCRIPT LANGUAGE="JavaScript">

    <!-- Beginning of JavaScript

    function ConfirmWin() {

    var response = window.confirm("Do you like programming in JavaScript?");

    if (response) {

    window.alert("Good Luck with your JavaScript Programming.");

    }

    else {

    window.alert("We hope we can show you how useful it is.");

    }

    }

    // - End of JavaScript - -->

    </SCRIPT>

    There would have to be a way to put in a code which would change the picture if (response) was OK. There just has to be a way...
    Copy linkTweet thisAlerts:
    @BonRougeApr 06.2005 — Well, I fixed the confirm/exit thing (I think)... I'm afraid I don't know anything about the music.

    What I said before about the javascript events cancelling each other out is still true as far as I can see. I'm not trying to be awkward, but I think this is the best I can do for you... (sorry...)
    ×

    Success!

    Help @tburton 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.17,
    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: @nearjob,
    tipped: article
    amount: 1000 SATS,

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

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