Why i should use buttons instead of links?

Author Message

Vytautas Germanavičius

Monday 13 June 2005 10:40:16 am

Can someone explain, whay this doeasn't work

<form method="post" action={"/content/action"|ezurl} name="newPhoto">
    <input type="hidden" name="NodeID" value="1180" />
    <input type="hidden"  name="ClassID" value="5" />        
    <a href="#" onclick="document.forms.newPhoto.submit()">Add Photo</a>
</form>

But if i change link with button, it works

<form method="post" action={"/content/action"|ezurl} name="newPhoto">
    <input type="hidden" name="NodeID" value="1180" />
    <input type="hidden"  name="ClassID" value="5" />        
<input type="submit" name="NewButton" value="{'Create here'|i18n('design/standard/node/view')}" />
</form>

{set-block scope=root variable=cache_ttl}0{/set-block}

Tom Couwberghs

Wednesday 15 June 2005 2:35:27 pm

I'm not entirely sure, but I believe the content/action script, needs the name of the submit-button to decide what action he will perform.

You can solve it like this:

-start from your working example
-hide the submit button with a touch of css (display:none)
-Make a link (with javascript) that will click your submit-button.

Hope this helps,

Tom

Vytautas Germanavičius

Thursday 16 June 2005 12:29:22 am

I solved problem in this way - i made hidden field instead of button. This works:

<form method="post" action={"/content/action"|ezurl} name="newPhoto">
    <input type="hidden" name="NodeID" value="1180" />
    <input type="hidden"  name="ClassID" value="5" />        
<input type="hidden" name="NewButton" value="{'Create here'|i18n('design/standard/node/view')}" />
    <a href="#" onclick="document.forms.newPhoto.submit()">Add Photo</a>
</form>

{set-block scope=root variable=cache_ttl}0{/set-block}

Maxime Thomas

Friday 03 March 2006 5:32:08 am

I found another solution. You can use the input image element :

<form action="/content/action" name="myform">
<input type="image" name="MyButton" src="logo.png" />
</form>

Rather than :

<form action="/content/action" name="myform">
<a href="javascript:document.myform.submit()">
<img src="logo.png"/>
</a>
<input type="hidden" name="MyButton"/>
</form>

Maxime Thomas
maxime.thomas@wascou.org | www.wascou.org | http://twitter.com/wascou

Company Blog : http://www.wascou.org/eng/Company/Blog
Technical Blog : http://share.ez.no/blogs/maxime-thomas

Xavier Dutoit

Friday 03 March 2006 6:04:07 am

I saw you found a solution, but to answer to your initial question:

everytime you have a from that perform an action that change the state of your system (add delete or modify), the W3C ask to use a post action (not a get, ie. not a link). This avoids, for instance, robots of the search engines creating zillions of drafts while indexing your site.

X+

http://www.sydesy.com

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 20:58:34
Script start
Timing: Jan 18 2025 20:58:34
Module start 'layout'
Timing: Jan 18 2025 20:58:34
Module start 'content'
Timing: Jan 18 2025 20:58:35
Module end 'content'
Timing: Jan 18 2025 20:58:35
Script end

Main resources:

Total runtime0.8357 sec
Peak memory usage4,096.0000 KB
Database Queries67

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0072 588.0469152.6406
Module start 'layout' 0.00720.0046 740.687539.4766
Module start 'content' 0.01170.8225 780.1641659.0938
Module end 'content' 0.83420.0014 1,439.257816.1250
Script end 0.8357  1,455.3828 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00390.4646160.0002
Check MTime0.00150.1808160.0001
Mysql Total
Database connection0.00130.150110.0013
Mysqli_queries0.753590.1616670.0112
Looping result0.00080.0898650.0000
Template Total0.794595.120.3972
Template load0.00230.276920.0012
Template processing0.792194.786820.3961
Template load and register function0.00010.013610.0001
states
state_id_array0.00080.097810.0008
state_identifier_array0.00110.134020.0006
Override
Cache load0.00210.2538320.0001
Sytem overhead
Fetch class attribute can translate value0.00070.085140.0002
Fetch class attribute name0.00110.135190.0001
XML
Image XML parsing0.00610.729540.0015
class_abstraction
Instantiating content class attribute0.00000.0020100.0000
General
dbfile0.01141.3693340.0003
String conversion0.00000.001240.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
5content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
5content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
8content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
5content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 26
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs