Fwd: Replacing Submit Buttons with Images ?????

Chuck Hagenbuch chuck@horde.org
Mon, 11 Jun 2001 10:47:16 -0400



----- Forwarded message from Douglas McCann <douglasmccann@eircom.net> -----
    Date: Mon, 11 Jun 2001 14:49:09 +0100
    From: Douglas McCann <douglasmccann@eircom.net>
Reply-To: douglasmccann@eircom.net
 Subject: Replacing Submit Buttons with Images ?????
      To: chuck@horde.org

Hi Chuck,

I have been hacking away at IMP and have run into a little problem. I'm trying 
to replace the send, save draft and cancel submit buttons with pictures, the 
options presented when you compose a letter. Here's the script that's causing 
me hassle. It's located within this file
   .../horde/imp/templates/compose/compose.inc


   <input type="submit" name="actionID" value="<?php echo $lang->button_cancel ?
>" onClick="return confirmCancel();">

   <?php if ($default->user_use_folders): ?>
   <input notab type="submit" name="actionID" value="<?php echo $lang-
>button_postpone ?>">
   <?php endif; ?>

   <input notab type="submit" name="actionID" value="<?php echo $lang-
>button_send ?>" onClick="return submit_and_sign(document.compose);">


In an ideal world I would love to be able to do the following for example 
(however this type of "submit" is not supported by Netscape. 
The onclick and value functionality are not allowed within the input tag where 
type=image):

    <input type="image" name="actionID" value="<?php echo $lang->button_cancel ?
>" onClick="return confirmCancel();">


The workaround I tried was: 

<script language="javascript">

function change_value_cancel(){
        document.compose.actionID.value="<?php echo $lang->button_cancel ?>";
        return;
}

function change_value_save(){
        document.compose.actionID.value="<?php echo $lang->button_postpone ?>";
        return;
}

function change_value_send(){
        document.compose.actionID.value="<?php echo $lang->button_send ?>";
        return;
}

</script>


<form method="post" name="compose" enctype="multipart/form-data" action="<?php 
$sess->purl('compose.php3?uniq=' . uniqid(rand())) ?>">

    <input type="hidden" name="actionID" value="_still_has_not_changed_">

    <a href="javascript:document.compose.submit()" onclick="change_value_cancel
(); return confirmCancel();">
    <img src="<?php echo $default->graphics_url ?>/cancelmessage.gif" border=0 
alt="Submit">
    </a>


    <?php if ($default->user_use_folders): ?>
    <a href="javascript:document.compose.submit();" onclick="change_value_save
();">
    <img src="<?php echo $default->graphics_url ?>/savedraft.gif" border=0 
alt="Submit">
    </a>
    <?php endif; ?>


    <a href="javascript:document.compose.submit()" onclick="change_value_send
(); return submit_and_sign(document.compose);"> 
    <img src="<?php echo $default->graphics_url ?>/sendmessage.gif" border=0 
alt="Submit">
    </a>




However, what happens is that the hidden value is always sent to throught 
the /horde/imp/compose.php3 file with the value as:

 _still_has_not_changed_returned 


Seemingly, the value set for type=hidden cannot be changed and sent to the 
receiving page using Javascript.


Here's an example I created just to see if I can change the value of a 
type "hidden". This code works. I'm now wondering if there's 
something going on in Imp that is not allowing me to implement this change.


<html>

<script>
function changeit()
{
        document.name1.id.value="value of function 1";
        return; 
}


function changeit1()
{
        document.name1.id.value="value of function 2";
        return; 
}

</script>


<form name="name1" method="post" action="preposting.php3">


    <input type="hidden" name="id" value="testvalue">
    
   <script>  document.write("ID 1 Original Value = " + 
document.name1.id.value);  </script>
    <a href="javascript:document.name1.submit()" onclick="changeit()"> Click To 
Change 
    </a>
    <?php   echo "ID 1 Final Value = $id" ?>

<p>

    <script>  document.write("ID 2 Original Value = " + 
document.name1.id.value);  </script>
    <a href="javascript:document.name1.submit()" onclick="changeit1()"> Click 
To Change 
    </a>
    <?php   echo "ID 2 Final Value = $id" ?>

</form>

</html>


I don't know how to get around this at the moment. Any ideas of how I can 
resolve this?
If you could shed any light on the situation or point me in the direction of a 
solution I'd greatly appreciate it.


Slan,
Is mise le meas,
         Dubhghlas MacCanna.

----- End forwarded message -----


-chuck

--
Charles Hagenbuch, <chuck@horde.org>
Some fallen angels have their good reasons.