Welcome Guest, Not a member yet? Register   Sign In
How to make anchor tag as sumbit?
#1

[eluser]coderedmax[/eluser]
as title says.. how can I implement submit using anchor tag?
#2

[eluser]eoinmcg[/eluser]
submit is a property of forms not anchors.

so the best solution would be to just use a form and style the submit button to look more like a link.

you can, also, use [removed]
Code:
<a href="#"></a>

where submit_something is a javascript function that submits the data.


edit: forgot to add the onclick handler to the <a>
#3

[eluser]toopay[/eluser]
use general javascript statement...
Code:
// Remove any backslash
<\a\ href="#" \onclick\="document.your_form_name_tag.submit();">Anchor Button</a>
#4

[eluser]Rok Biderman[/eluser]
Well, since submit is generally useless without a form, you might as well use the form helper and do the
Code:
$this->load->helper('form');
echo form_open('do/something');
echo form_input('username', 'johndoe');
echo form_submit('submitbutton', 'Submit Post!');
echo form_close();

This solves it and adds a csrf hidden field as well for added security (if configured). Now I know that isn't exactly the answer to your question (toopay answered that), but you have no use for submit without a form in the first place. If you did, for a jquery ajax request or such, you could easily bind it to any element, it wouldn't have to be type submit.
#5

[eluser]coderedmax[/eluser]
thanks for all response. Problem Solved :-)

I've decided to use submit form rather than using <a> tags(using javascript) more easy to implement because I'm having hard time using windows event.

Code:
<div id="send-new-message">

&lt;?php
echo form_open('msg/send_new_message');
echo form_submit('submit', 'Send New Message');
echo form_close();
?&gt;

</div>


CSS

Code:
#send-new-message input[type=submit] {
    background: none;
    padding: 0px;
    font-family: tahoma, arial, verdana;
    font-size: 11px;
    font-weight: normal;
    cursor: pointer;
    border: none;
    color: #820c27;
}

I think more secure. anyway thanks again to all of you guys =) cheers!




Theme © iAndrew 2016 - Forum software by © MyBB