Welcome Guest, Not a member yet? Register   Sign In
How to invoke a button action when I don't want to use javascript to do the same ?
#1

[eluser]quest13[/eluser]
Hi, I have a following code that creates a edit button and on clicking it, edit form populates into different page. I did it by using js. But if I want to avoid it, Is there any way I can do it ? Can anyone help me out ?

Here is the code :

echo "<th>&lt;input type=\"button\" name=\"Editcat\" value=\"Edit\"&gt;";



Thanks in advance,.
#2

[eluser]Thorpe Obazee[/eluser]
[quote author="quest13" date="1243932751"]Hi, I have a following code that creates a edit button and on clicking it, edit form populates into different page. I did it by using js. But if I want to avoid it, Is there any way I can do it ? Can anyone help me out ?

Here is the code :

echo "<th>&lt;input type=\"button\" name=\"Editcat\" value=\"Edit\"&gt;";



Thanks in advance,.[/quote]

I'm confused. Where's the code? Btw, use [ code] [ /code] next time.
#3

[eluser]quest13[/eluser]
Sorry,
this is the code :

<table>

<tr>

<th>SubcategoryId</th>
<th>CategoryId</th>
<th>SubcategoryName</th>
<th colspan="2">Action</th>
</tr>
&lt;?php foreach($result->result_array() as $SubCat_data):?&gt;
<tr>
<th>&lt;?=$SubCat_data['SubCategoryId'];?&gt;</th>
<th>&lt;?=$SubCat_data['CategoryId'];?&gt;</th>
<th>&lt;?=$SubCat_data['SubCategoryName'];?&gt;</th>

&lt;?php
$subcatid=$SubCat_data['SubCategoryId'];
$catid=$SubCat_data['CategoryId'];
$catname=$SubCat_data['SubCategoryName'];

?&gt;

&lt;?php

echo "<th>&lt;input type=\"button\" name=\"EditSubcat\" value=\"Edit\"&gt;";
echo "&lt;input type=\"button\" name=\"DelSubcat\" value=\"Delete\"&gt;&lt;/th>";
?&gt;


</tr>
&lt;?php endforeach;?&gt;

</table>


Once I click a "Edit" button, the control should go to the function "EditSubcat" in the controller and I should be able to view the form called "Edit form".

Thank you
#4

[eluser]Thorpe Obazee[/eluser]
If you intend to you the button, you should have a form tag

Code:
&lt;?php echo form_open('your/uri/string/to/edit/the_id'); ?&gt;
echo “<th>&lt;input type=\“button\” name=\“EditSubcat\” value=\“Edit\”&gt;”;
&lt;?php echo form_close(); ?&gt;

you can also use a hidden input for storing the id you want to edit.

Code:
&lt;?php echo form_open('your/uri/string/to/edit'); ?&gt;
echo “<th>&lt;input type=\“button\” name=\“EditSubcat\” value=\“Edit\”&gt;”;
echo “<th>&lt;input type=\“hidden\” name=\“me\” value=\“id\”&gt;”;
&lt;?php echo form_close(); ?&gt;
#5

[eluser]kgill[/eluser]
Is there some reason you aren't posting the form via a submit button? That would be the simplest method...
#6

[eluser]quest13[/eluser]
Thank you !

I used form_open and submit method, passed the uri and job is done.

Thanks again




Theme © iAndrew 2016 - Forum software by © MyBB