Welcome Guest, Not a member yet? Register   Sign In
More of a html problem... i think?
#1

[eluser]Tom Taila[/eluser]
Ok so basically i want to have two submit buttons for posting a comment, one of which will post the users comment as per usual with all their details displayed in their comment post and the other button is supposed to "post as annonymous" where it does as you'd expect and post it annonymously, so heres the html code i have for my form:

Code:
<form action="<?php echo base_url();?>index.php/comment/add_comment1" method="post" id="comment_form">
                      <textarea name="comment" id="comment_textarea">Write a comment..</textarea><br />
                      <p>&lt;input type="submit" value="Post!" class="submit_comment_button"/&gt; | &lt;input type="submit" value="Post as anonymous!" class="submit_comment_anonymous_button"/&gt;&lt;/p>
                &lt;/form&gt;

but this simply creates two buttons for the same purpose, any1 know a way to do this i cant find one :S

sorry i know this isnt very codeigniter related
#2

[eluser]benurv[/eluser]
use php isset to check wich button is posting and catch it in your controller
#3

[eluser]Buso[/eluser]
in your form:
Code:
&lt;input type='submit' name='submit' value='Post!'/&gt;&lt;input type='submit' name='submit' value='whatever'/>

in your controller:
Code:
if($this->input->post('submit')=='Post!') {
  // do something
} else {
  // whatever
}

I think it may also work if you set different names for your submit buttons, eg: button1 and 2, and then just do this:
Code:
if($this->input->post('button1')) {
  // do something
} else {
  // whatever
}
#4

[eluser]Tom Taila[/eluser]
hmm sounds like it would work, ill give it a try later today im just finishing up some other code i started, but thanks so much and sorry for the late reply ive been very busy! cheers
#5

[eluser]Tom Taila[/eluser]
Yup Buso the first method u suggested worked fine, thanks so much to both of you, cheers guys Smile
#6

[eluser]Tom Taila[/eluser]
a




Theme © iAndrew 2016 - Forum software by © MyBB