Welcome Guest, Not a member yet? Register   Sign In
POST and anchor problem
#1

[eluser]cinewbie81[/eluser]
Hi all,

I have a question regarding POST function and anchor function.
The following is my "test" controller class:
Code:
<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');

class Test extends Controller {

    function Test()
    {    
        // Load neccessary helper file, library etc
        parent::Controller();
        $this->load->helper(array('url','form'));
    }

    function index()
    {

        $this->load->view('home/home_test_view', $data);
    }


    function verification()
    {
        if ($this->input->post('save_y')) {
            echo $this->input->post('customer_name');
        }    
    }
}
?>


and my "test" view page:
Code:
<?php $this->load->view("header"); ?>
<?php echo form_open('test/verification');?>

            <input type="image" name="send" src="<?php echo base_url();?>images/save.gif" value="Save" alt="Save" title="Save">
            
            <table border="0" height="100%"  id="tablesetting">
                <tr>
                    <td>Name:</td>
                    <td>&lt;?php echo form_input('customer_name', '');; ?&gt;</td>
                </tr>            
            
            </table>            

&lt;?php echo form_close();?&gt;
&lt;?php $this->load->view("footer"); ?&gt;

According to the code above, when i type something - let's say 'John' into customer_name input and press 'F5' to refresh the page, the value for customer_name input still remain 'John' . I want to set the value to original state - which is blank.

Then i found out that it's because of the form_open and form_close in my code. Comment out these two statement will get the customer_name input become blank after refresh.

Anyway, if i comment out form_open and form_close, how am i going to pass the 'customer_name' value to the controller class when i click at the 'save' button ?? I know it can be solved by using "anchor('test/verification/customer_name', 'Save')" instead of using "button", but i dont want it to be this way because it make my url looks like so complicated. Anyone help ? Thanks
#2

[eluser]thurting[/eluser]
Just write out the HTML yourself. If you use the helper you are forced to use CI's conventions. If you don't want them, don't use the helper.
#3

[eluser]cinewbie81[/eluser]
It's the same if i write the HTML myself ..
i dont think it has anything to do with CI though ..
just dont know where went wrong
#4

[eluser]bijon[/eluser]
I think it's may be in your browser problem . May be in you browser remember it. So try to use IE , MOzilla and check any thing is differet.
#5

[eluser]Michael Wales[/eluser]
Yeah - I think it is definitely a browser issue. I don't use the form helper for inputs but I don't believe it assigns a "value" parameter.

Even if it did, you would then be getting errors because I know it would use the Validation class (which you don't have loaded). In addition, the validation library wouldn't know the value of validation->customer_name until you run the set_fields() method and submit the form.

So yeah - it's your browser, not CI.
#6

[eluser]cinewbie81[/eluser]
Yeh it's browser problem..
I test it on IE and it works just fine ..
how am i going to solve this problem in Mozilla thenm ??? I believe a lot of clients using Mozilla as well .. any idea ? thanks
#7

[eluser]Michael Wales[/eluser]
ignore it? It doesn't really even sound like a problem to me - it's what Mozilla users would expect.

If I started filling out a form, and had to refresh prior to submitting it (for some odd reason), then I noticed the form was reset? Well, forget it, that form isn't getting filled out.
#8

[eluser]mistress_shiira[/eluser]
i have a small app here that has those form dropdown and basically it works.i just dont know what makes it work though. Smile
#9

[eluser]cinewbie81[/eluser]
Hi,

Yeh it seems like not a big problem in this case ..
Anyway, i have a hidden value that will be used which will be use along with the javascript .. if user didn't press F5 it works correctly .. but if user press F5, the hidden value will duplicate in javascript thus generate some bizarre result .. that's what i concern
#10

[eluser]mistress_shiira[/eluser]
then i think thats not a good way of doing that cause users would usually press F5. Smile
what is the hidden field for anyways?




Theme © iAndrew 2016 - Forum software by © MyBB