Value of Rollover Submit Buttons

Discussion in 'Javascript' started by JR, Mar 4, 2004.

  1. JR

    JR Guest

    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>
     
    JR, Mar 4, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. dave

    rollover buttons

    dave, May 12, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    1,424
  2. Leythos
    Replies:
    4
    Views:
    3,632
    Leythos
    Mar 30, 2005
  3. Doug
    Replies:
    2
    Views:
    433
  4. Replies:
    4
    Views:
    1,012
  5. Gepi Solo

    PyGTK - Rollover Buttons

    Gepi Solo, Sep 7, 2006, in forum: Python
    Replies:
    0
    Views:
    416
    Gepi Solo
    Sep 7, 2006
Loading...

Share This Page