Value of Rollover Submit Buttons

J

JR

Hi.

I have the following javascript problem that is driving me crazy. I
hope someone in this group can help!

I have the below javascript and html code that serves to create a
submit button rollover (I only included two buttons in this message,
but there are many more than just these two). The rollover works fine
in the version of IE and NN that we use in our office; however, when I
submit the form, I can't determine from the output which submit button
was selected. I need to be able to determine this, in order to know
which action the receiving CGI program should take. Is there anyway
to do this, or should I just use a drop-down menu instead of rollover
submit buttons? I tried unsuccessfully to pass the button name as a
hidden value, and just don't know what else to try. When I attempted
to pass the button name as a hidden value, it passed both button
names. I think this is because the function is called twice, but for
the rollover to work, I think it has to be called for each onMouseOver
event. I'm a relative novice at Javascript, and the rollover script
is borrowed from an online source.

Is what I'm attempting doable?

Thanks!!!


############ javascript code ############

var submitRolls = new Object();

function submitroll(src, oversrc, name) {
this.src=src;
this.oversrc=oversrc;
this.name=name;
this.alt="Submit Query";
this.write=submitroll_write;
}

function submitroll_write() {
var thisform = 'document.forms[' + (document.forms.length - 1) +
']';
submitRolls[this.name] = new Object();
submitRolls[this.name].over = new Image();
submitRolls[this.name].over.src = this.oversrc;
submitRolls[this.name].out = new Image();
submitRolls[this.name].out.src = this.src;

document.write (
'<A onMouseOver="if (document.images)document.images[\'' +
this.name + "'].src=submitRolls['" + this.name + '\'].over.src"' +
' onMouseOut="if (document.images)document.images[\'' +
this.name + "'].src=submitRolls['" + this.name + '\'].out.src"' +
' HREF="javascript:'
);

if (this.sendfield) {
if (! this.sendvalue) {
this.sendvalue = 1;
}
document.write(thisform, ".elements['", this.sendfield,
"'].value='", this.sendvalue, "';");
}

document.write(thisform + '.submit();void(0);"');
if (this.msg) {
document.write(' onClick="return confirm(\'' , this.msg,
'\')"');
}

document.write('>');

document.write('<IMG SRC="' + this.src + '" ALT="' + this.alt +
'" BORDER=0 NAME="' + this.name + '"');
document.write('></A>');
//document.write('<input type=hidden name="' + this.name + '"
value="' + this.sendfield + '">');
if (this.sendfield) {
document.write('<INPUT TYPE=HIDDEN NAME="' + this.sendfield +
'">');
document.forms[document.forms.length -
1].elements[this.sendfield].value='';
}
}

############ html code ############

<BASE HREF="memo">
<html>
<head>
<script language="JavaScript1.2" src="memo.js">
</script>
</head>
<body bgcolor=beige>
<center>
<form name = "Form1" action="action.cgi" method="get">
<A onMouseOver="if (document.images)document.images['Download
Record'].src=submitRolls['Download Record'].over.src" onMouseOut="if
(document.images)document.images['Download
Record'].src=submitRolls['Download Record'].out.src"
HREF="javascript:document.forms[0].submit();void(0);">
<IMG SRC="download_record_off.gif" ALT="Submit Query" BORDER=0
NAME="Download Record"></A><A onMouseOver="if
(document.images)document.images['Save & Next'].src=submitRolls['Save
& Next'].over.src" onMouseOut="if
(document.images)document.images['Save & Next'].src=submitRolls['Save
& Next'].out.src" HREF="javascript:document.forms[0].submit();void(0);"><IMG
SRC="save_and_next_off.gif" ALT="Submit Query" BORDER=0 NAME="Save &
Next"></A>
<INPUT type=hidden name=user value="xyz">
<INPUT type=hidden name=session value="20040303fvCt9891y5">
<INPUT type=hidden name=memo_type value="xyzg">
<INPUT type=hidden name=page value="1">
<INPUT type=hidden name=menu value="1">
</html>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top