[imp] Fwd: Replacing Submit Buttons with Images ?????

Randy Miller rmiller@highwired-inc.com
Mon, 11 Jun 2001 11:06:17 -0400


This problem also had me stumped for a little bit.

My solution to this problem is pretty gross, but it works.  My links look like:

<a href="javascript: mysubmit(document.compose, 'Cancel Message')"><img 
src= "/horde/imp/graphics/pub_cancel_message.gif" border="0"></a>
     <a href="javascript: mysubmit(document.compose, 'Save Draft')"><img 
src="/horde/imp/graphics/pub_savedraft.gif" border="0"></a>
     <a href="javascript: mysubmit(document.compose, 'Send Message')"><img 
src="/horde/imp/graphics/pub_send_message.gif" border="0"></a>

and mysubmit is:

function mysubmit (form, action) {
         myerror='';
         if (action == 'Send Message') {
            if (submit_and_sign(form)) {
                 form.action = form.action + '&actionID=Send+Message';
            } else {
                 myerror = 'y';
            }
         }
         if (action == 'Cancel Message') {
                 if (confirmCancel()) {
                         form.action = form.action + 
'&actionID=Cancel+Message';
                 } else {
                         myerror = 'y';
                 }
         }
         if (action == 'Save Draft') {
                 form.action = form.action + '&actionID=Save+Draft';
         }
         if (action == 'Remove Attachments') {
                 attach_delete();
                 form.action = form.action + '&actionID=Remove+Attachments';
         }
         if (action == 'Attach') {
                 form.attachmentAction.value = 'add';
                 if (attachment_check(document.compose)) {
                         form.action = form.action + '&actionID=Attach';
                 } else {
                         myerror='y';
                 }
         }
         if (myerror != 'y') {
                 form.submit();
         }
}


At 10:47 AM 6/11/01 -0400, you wrote:


>----- 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.
>
>
><javascript:document.name1.submit()>Click To Change <?php echo "ID 1 Final 
>Value = $id" ?>
>
><javascript:document.name1.submit()>Click To Change <?php echo "ID 2 Final 
>Value = $id" ?>
>
>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.
>
>--
>IMP mailing list: http://horde.org/imp/
>Archive: http://marc.theaimsgroup.com/?l=imp&r=1&w=2
>Frequently Asked Questions: http://horde.org/faq/
>To unsubscribe, mail: imp-unsubscribe@lists.horde.org


Randy Miller -- Team Leader, Web Development
HighWired.com -- Your high school connection
http://www.highwired.com/
rmiller@highwired-inc.com -- 617.393.2233