/    Sign up×
Community /Pin to ProfileBookmark

Java Script Inside a Form?

Is it possible?

I have a form for my shopping cart/PayPal. It reads as follows:

<FORM METHOD=”POST” ACTION=”/cgi-healin-hollers/basket”>
<INPUT TYPE=”HIDDEN” NAME=”command” VALUE=”enter”>
<INPUT TYPE=”HIDDEN” NAME=”merchant” VALUE=”healinhollers”>
<INPUT TYPE=”HIDDEN” NAME=”item” VALUE=”101″>
<INPUT TYPE=”image” SRC =”http://www.healin-hollers.com/images/addtocartbutton-t.gif”name=”Add To Order” width=”85″ height=”20″>
</FORM>

I am wanting to change the static “addtocartbutton-t.gif” with an Image Flip. The body code for that is:

<A HREF=”/cgi-healin-hollers/basket” onMouseOver=”SwapOut()” onMouseOut=”SwapBack()”>
<IMG NAME=”imageflip” SRC=”/images/showbutton.gif” WIDTH=85 HEIGHT=20 BORDER=0></A>

The Heading code is:

<SCRIPT LANGUAGE=”JavaScript”>
<!– hide from none JavaScript Browsers

Image1= new Image(85,20)
Image1.src = “images/showbutton.gif”
Image2 = new Image(85,20)
Image2.src = “images/addtocartbutton.gif”

function SwapOut() {
document.imageflip.src = Image2.src; return true;
}

function SwapBack() {
document.imageflip.src = Image1.src; return true;
}

// – stop hiding –>
</SCRIPT>

When I do this outside of the form, it works fine.

When I try to put the body code it into the form, substituting it for the old static gif, it all goes south.

Any help will be appreciated.
Reply With Quote

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @Arkinsaw 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,
)...