CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Images to submit Delete, Cancel for a form - how?

Print topic Send  topic

Author Message
Jeff Walters
Posted: 11/29/2004, 1:01 AM

How do I use images to submit either a Cancel or Delete? If I change the
submit Delete button to an image input type, I get a Submit Update action -
for both Delete and Cancel.

I have tried using a hidden field + onclick javascript to submit the form.
(used to be able to do this with CC - and ASP - Hidden field name
FormAction), but don't know how to get the CCS / PHP code to pick this up /
process the Delete or Cancel methods / any associated customer code /
actions. Is there a specific field name to use, that will enable the
generated code to determine that either one of these buttons have been
pressed?

Anybody done this within the CCS framework - I don't want to break the
generated code - rather just want to either tweak the html template with
javascript, or embed a couple of lines in custom code segments? I was able
to do this pretty easily in ASP.Net - and hope that I can achieve the same
with PHP.

I am very new to PHP - I have worked in ASP and ASP.Net, but want to switch
to PHP generation for a major project - so an explicit example / snippet of
code please - as I am still struggling through the syntax changes.

Thanks in hope

Jeff

Damian Hupfeld
Posted: 11/29/2004, 5:16 AM

Without having tried what you are doing, and without the time to test it...
as a really quick fix you could modify the button style and have an image as
the button background?
Here is a CSS line that I have used an image as the background for the hover
action -
#menu a:hover {border: 1px solid #000000; background-image:
url(../../images/menubck1.gif); color: #FFFFFF;}

regards
Damian Hupfeld
http://www.nexthost.com.au/services.php
Jeff Walters
Posted: 11/30/2004, 6:56 AM

I had quick followup from Helen - CC Support - who provided me with a clear
explanation on how to use a hidden field / associated javascript.

Excellent support - thanks.

Jeff
Don Safar
Posted: 11/30/2004, 7:41 AM

Why don't you share this with the rest of us? Thanks!
klwillis


Posts: 428
Posted: 11/30/2004, 11:47 AM

I'd like to know this bit of trickery myself. Sounds neat! ;)

Quote Jeff Walters:
I had quick followup from Helen - CC Support - who provided me with a clear
explanation on how to use a hidden field / associated javascript.

Excellent support - thanks.

Jeff


_________________
Kevin Willis, VP/CIO
HealthCare Information Technology Specialist
http://www.nexushealthcare.com
"Fast - Convenient - Quality-Care"

Medical Software Consulting Services
Email : klwillis@nexushealthcare.com
Skype : klwillis2006
View profile  Send private message
peterr


Posts: 5971
Posted: 11/30/2004, 1:30 PM

I pulled the answer from our support system:

Quote :
You need to use CCS Hidden control in the HTML, then use JavaScript code to pass different parameters:
function update() {
document.ages1.Hidden1.value = "Submit";
document.ages1.Hidden1.name= "Button_Update";
document.ages1.submit();
}

When you click an image link the JS code is fired and the Hidden control gets the corresponding name and the value. Thus when form is submitted the operation name (e.g. Submit) and button name are passed as parameters from the form. Those parameters are read by the code and execture corresponding operations (insert, update, delete).

I successfully use the following JS code:
<script language = "JavaScript">
function insert() {
document.ages1.Hidden1.value = "Add";
document.ages1.Hidden1.name= "Button_Insert";
document.ages1.submit();
}

function update() {
document.ages1.Hidden2.value = "Submit";
document.ages1.Hidden2.name= "Button_Update";
document.ages1.submit();
}

function delete_f() {
document.ages1.Hidden3.value = "Delete";
document.ages1.Hidden3.name= "Button_Delete";
document.ages1.submit();
}
</script>

And here is the relevant HTML (please remember about using Hidden CCS controls, not just HTML code)
<a href="javascript:insert()"> <img src=images/Insert.gif> </a>
<input type="hidden" name="{Hidden1_Name}" value="{Hidden1}">
<a href="javascript:update()"> <img src=images/Update.gif> </a>
<input type="hidden" name="{Hidden2_Name}" value="{Hidden2}">
<a href="javascript:delete_f()"> <img src=images/Delete.gif> </a>
<input type="hidden" name="{Hidden3_Name}" value="{Hidden3}">

_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
Jeff Walters
Posted: 12/01/2004, 8:23 AM

The solution that Helen provided worked, However, I wanted to simplify it to
minimise the modifications that I would have to make to a standard
wizard-generated page.

The following process seems to work:
- I generate one or more pages using the standard page generation wizards.
This places the standard submit buttons on the update forms.

- I merely change the property setting from Submit to Image, and provide
the image source for each button.

- I place 1 hidden control - not 3 - on the form, and for brevity name it
H1.

- I do not create javascript functions - I prefer to use in-line javascript
for OnClick statement for each button:

<!-- BEGIN Button Button_Insert --><input name="{Button_Name}"
type="image" value="Add" src="images/insert.png" alt="Add the record and
return to calling page"
onclick="document.{HTMLFormName}.H1.value =
'Add';document.{HTMLFormName}.H1.name= '{Button_Name}';"><!-- END Button
Button_Insert -->
<!-- BEGIN Button Button_Update --><input name="{Button_Name}"
type="image" value="Submit" src="images/update.png" alt="Update the record
and return to calling page"
onclick="document.{HTMLFormName}.H1.value =
'Submit';document.{HTMLFormName}.H1.name= '{Button_Name}';"><!-- END Button
Button_Update -->
<!-- BEGIN Button Button_Delete --><input name="{Button_Name}"
type="image" value="Delete" src="images/delete.png" alt="Delete the record
and return to calling page"
onclick="javascript:document.{HTMLFormName}.H1.value =
'Delete';document.{HTMLFormName}.H1.name= '{Button_Name}';return
confirm('Are you sure');"><!-- END Button Button_Delete -->
<!-- BEGIN Button Button_Cancel --><input name="{Button_Name}"
type="image" value="Cancel" src="images/undo.png" alt="Cancel all changes
and return to calling page"
onclick="javascript:document.{HTMLFormName}.H1.value =
'Cancel';document.{HTMLFormName}.H1.name= '{Button_Name}'"><!-- END Button
Button_Cancel -->  </td>

I have tried to use the generic names - e.g. .{HTMLFormName} and
'{Button_Name} - so I can merely drop this code in without any customisation
per form.

- Note - I did not include the Submit() call in each OnClick - this appears
to happen with clicking on the image anyway, so all I use the OnClick
statement to do is to correctly set the HI value / name.
Seems to work fine - I have tried embedded custom actions / code on the
server side of form deletes / cancel, and they 'fire' correctly.

So far no hassles with my mods / slightly simpler code additions.

HTH

Jeff
klwillis


Posts: 428
Posted: 12/01/2004, 8:57 AM

Very nice. ;-)
_________________
Kevin Willis, VP/CIO
HealthCare Information Technology Specialist
http://www.nexushealthcare.com
"Fast - Convenient - Quality-Care"

Medical Software Consulting Services
Email : klwillis@nexushealthcare.com
Skype : klwillis2006
View profile  Send private message
Joshua McDonald
Posted: 12/21/2004, 6:52 AM

Hello All,

This works fine but how would I get the image to update and take it to another page instead of the default page?

Joshua
Help me
Posted: 01/22/2005, 11:58 AM

what is this H1. Please explain in detail...
peterr


Posts: 5971
Posted: 01/22/2005, 12:30 PM

From the above description it is hidden control: "I place 1 hidden control - not 3 - on the form, and for brevity name it H1."
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
Help Me
Posted: 01/22/2005, 12:44 PM

Hi peter.....

I thought it was the element of that current form. But I have a scenario where I don't have any form name. Only with action and method to post.
So, I named the form = "loginform".

I get an error message----- 'document.loginform.login' is null or not an object.

Please don't mind if I irritate you. I don't know anything about java.


<form name="loginform" action="{S_LOGIN_ACTION}" method="post">
<input type="text" name="username" class="post" size="10" maxlength="40" value="{USERNAME}" />
<input type="password" name="password" class="post" size="10" maxlength="32" />
{S_HIDDEN_FIELDS}
<input name="login" type="image" value="{L_LOGIN}" src="images/golog.jpg" width="25" height="16" alt="login"
onclick="javascript:document.loginform.login.value = '{L_LOGIN}';document.loginform.login.name= 'login'">
</form>
peterr


Posts: 5971
Posted: 01/22/2005, 12:58 PM

Oops, I probably know as much JavaScript as you do. I could only point to the explanation for your previous question.
You may need to wait for someone else to answer, or try analyzing the above, or try other solutions:
http://www.google.com/search?hl=en&lr=&q=replace+buttons+%2Bwith+images
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
Thanks for reply
Posted: 01/22/2005, 1:14 PM

Got it going peter.

I put it this way.

<input name="login" type="image" value="{L_LOGIN}" src="images/golog.jpg" width="25" height="16" alt="login"
onclick="javascript:document.value = '{L_LOGIN}';document.name= 'login'">

Thanks for your prompt reply.
datadoit.com
Posted: 07/20/2005, 9:21 AM

I really don't understand why all of the javascript and hidden fields are
needed. I simply just let CCS create the grey buttons on my form, which
look like:

<!-- BEGIN Button Button_Update --><input type="submit" value="Submit"
name="{Button_Name}"><!-- END Button Button_Update -->

and simply change to:

<!-- BEGIN Button Button_Update --><input type="image"
src="images/whatever.gif" value="Submit" name="{Button_Name}"><!-- END
Button Button_Update -->

This did the trick for me. No other changes needed. Am I missing something
here?

-MikeR


Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.