Forums / Developer / Why i should use buttons instead of links?

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

eZ debug

Timing: Jan 18 2025 18:35:09
Script start
Timing: Jan 18 2025 18:35:09
Module start 'content'
Timing: Jan 18 2025 18:35:10
Module end 'content'
Timing: Jan 18 2025 18:35:10
Script end

Main resources:

Total runtime1.2289 sec
Peak memory usage4,096.0000 KB
Database Queries204

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0059 587.8438180.8125
Module start 'content' 0.00591.0755 768.6563664.1875
Module end 'content' 1.08140.1475 1,432.8438341.0547
Script end 1.2288  1,773.8984 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00390.3163210.0002
Check MTime0.00140.1170210.0001
Mysql Total
Database connection0.00090.071110.0009
Mysqli_queries1.151193.66942040.0056
Looping result0.00210.16932020.0000
Template Total1.202597.920.6012
Template load0.00220.177920.0011
Template processing1.200397.672220.6001
Template load and register function0.00010.009610.0001
states
state_id_array0.00090.071510.0009
state_identifier_array0.00110.089920.0006
Override
Cache load0.00190.1518320.0001
Sytem overhead
Fetch class attribute can translate value0.00120.098350.0002
Fetch class attribute name0.00100.081390.0001
XML
Image XML parsing0.00280.224850.0006
class_abstraction
Instantiating content class attribute0.00000.0015100.0000
General
dbfile0.00250.2072450.0001
String conversion0.00000.000430.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/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