/    Sign up×
Community /Pin to ProfileBookmark

Change an input image field in a timeout

Hello,

I have an input type=image tag likre this :

<form method=”post” action=”2.php”>
<input name=”Image1″ type=”image” onMouseOut=”MM_swapImgRestore(); text_disappear(2)” onMouseOver=”MM_swapImage(‘Image1′,”,’media/next_b.png’,1); text_appear(2)” src=”media/next_a.png”>
</form>

And I want in a Timeout this tag to be replaced with this one :

<form method=”post” action=”2.php”>
<input name=”Image1″ type=”image” onMouseOut=”MM_swapImgRestore(); text_disappear(2)” onMouseOver=”MM_swapImage(‘Image1′,”,’media/next_d.gif’,1); text_appear(2)” src=”media/next_c.gif”>
</form>

The only difference is in the images in it (both mouseout and mouse over)

I wandered of an easy way to do it?

Thank you very much

to post a comment
JavaScript

11 Comments(s)

Copy linkTweet thisAlerts:
@phpnoviceMay 29.2005 — 15-minute timeout:
[code=html]
<body onload="
window.setTimeout('document.forms[0].Image1.src='media/next_c.gif';', 15*60*1000);
return true;">
[/code]
Copy linkTweet thisAlerts:
@gebezisauthorMay 29.2005 — No, this would not help me.

I want to change the the whole input because the code you've posted would change only the original image(one image), and I want to change the image and the Mouse Over image too.

I meen that the new image has it's own rollover image too. If I use this code and point over the button it will swap to the previous rollover.

In the code I've posted, the function:

MM_swapImage('Image1','','media/next_d.gif',1);

swaps the image in a rollover, and the function:

MM_swapImgRestore();

restores the original image.

I want them both changed in a timeout - the original and the mouseOver.

Do you think I could do it with document.getElementById().innerHTML = "<input....>" ?

and puttind div tags around the <input> in the document itself?
Copy linkTweet thisAlerts:
@phpnoviceMay 29.2005 — No, this would not help me.

I want to change the the whole input because the code you've posted would change only the original image(one image), and I want to change the image and the Mouse Over image too.[/QUOTE]

Sorry, I missed that you had also made a change in the event code on the second bit of code you posted.

Here ya go:
[code=html]
<head>
...etc...
<script type="text/javascript">
<!--//
function myTimeout() {
var fld = document.forms[0].Image1;
fld.src = "media/next_c.gif";
fld.onmouseover = function() {
MM_swapImage('Image1', '', 'media/next_d.gif', 1);
text_appear(2);
return true;
}
}
//-->
</script>
</head>

<body onload="
window.setTimeout('myTimeout()', 15*60*1000);
return true;">
[/code]
Copy linkTweet thisAlerts:
@gebezisauthorMay 29.2005 — Thank you but it gives me an error masage :

"undefined" is null or not an object

If my form has a name should I write

document.forms["name"].Image1

or I should write the number of the form (in this example it is second)

Sorry for the stupid questions, I'm really a novice and If I weren't in a hurry with this job I would read more books instead of loosing your time.

Thank you very much
Copy linkTweet thisAlerts:
@phpnoviceMay 29.2005 — Which line actually gives you this error? Otherwise... Yes, you can put your form name in that statement.
Copy linkTweet thisAlerts:
@gebezisauthorMay 29.2005 — this one:

fld.onmouseover = function() {
Copy linkTweet thisAlerts:
@phpnoviceMay 29.2005 — If you can zip up and post a copy of your complete page, then I can run it through my script debugger and find the source of the problem.
Copy linkTweet thisAlerts:
@gebezisauthorMay 29.2005 — Here are the files:

the main is 1.php

the script is in JavaScript.php

After the mp3 finishes the "next" button should be replaced with a flashing one (you can see them in the media folder)

[upl-file uuid=42c553b3-7c19-4b95-8585-8aa54114316a size=85kB]New Folder.zip[/upl-file]
Copy linkTweet thisAlerts:
@phpnoviceMay 29.2005 — Because of the PHP code, I can't effectively debug your page from my computer. Thus, if you can supply a live link to your page on the Internet, I should be able to debug it from there.
Copy linkTweet thisAlerts:
@gebezisauthorMay 29.2005 — Anyway, many thanks for your effords, I decided to make it with document.getElementById().innerHTML = "<input...."

It works fine for me.

Best Regards : Eva
Copy linkTweet thisAlerts:
@phpnoviceMay 29.2005 — Cheers.
×

Success!

Help @gebezis 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 5.18,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...