This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit ezplatform.com

eZ Community » Forums » Developer » Why i should use buttons instead of...
expandshrink

Why i should use buttons instead of links?

Why i should use buttons instead of links?

Monday 13 June 2005 7:40:16 pm - 4 replies

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>

Wednesday 15 June 2005 11: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

Thursday 16 June 2005 9: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>

Friday 03 March 2006 2:32:08 pm

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>

Friday 03 March 2006 3:04:07 pm

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+

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from