Welcome Guest, Not a member yet? Register   Sign In
Problem after press 'Refresh' key
#1

[eluser]cinewbie81[/eluser]
Code:
<?php $this->load->view("header"); ?>
<?php echo form_open('customer/verification');?>

    <div id="actionmenu">
        &lt;input type="image" name="Save" src="&lt;?php echo base_url();?&gt;images/save.gif" value="Save" alt="Save"&gt;
        &lt;input type="image" name="Cancel" src="&lt;?php echo base_url();?&gt;images/cancel.gif" value="Cancel" alt="Cancel"&gt;
    </div>        

            
    <table border="0" cellpadding="0" cellspacing="0" height="100%" id="tablesetting" align="center">

        <tr>
            <td>Name:</td>
            <td>&lt;?php echo echo form_input('CustomerName', '');; ?&gt;</td>
        </tr>
        
    
        <tr>
            <td>Gender:</td>
            <td>&lt;?php    
                $options = array('0'  => 'Male','1'  => 'Female');
                echo form_dropdown('gender', 'gender', $options,'0');
                ?&gt;
            </td>
        </tr>        
            
    </table>    



&lt;?php echo form_close();?&gt;

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

I have a Customer View Page as shown above:
Notice that I have the following input elements on my form

a) Save Image button
b) Cancel Image button
a) 'CustomerName' input type
b) 'Gender' dropdown menu box

When I change the Gender value from 'Male' to 'Female', and press 'F5' key to refresh the page, the value for 'Gender' dropdown menu still return me 'FEMALE' on the page. I want it to be in the original state value- which is 'Male'. How can i do it ?? The same thing goes for CustomerName input type, after i press 'F5' it should return me an empty value.

ANyone ? Thanks in advance
#2

[eluser]mistress_shiira[/eluser]
have you tried adding this as the value of your element?
Code:
$this->validation->element_ID
i assume you have validation process before this. Smile
#3

[eluser]cinewbie81[/eluser]
Hi,

No, i dont have any validation process before this as this is just a testing (and i dont know how validation works too atm, haven't look through the documentation yet) ...

This is my controller class:
Code:
&lt;?php
if (!defined('BASEPATH')) exit('No direct script access allowed');


class Customer extends Controller {


    // Constructor
    function Customer()
    {
        parent::Controller();
        $this->load->helper(array('url', 'form'));
    }

    function index()
    {
        $this->load->view('customer_view', $data);
    }

    function verification()
    {
        // do verification here
    }    
}
?&gt;

How can i get it works ? thanks.
#4

[eluser]mistress_shiira[/eluser]
when you do a form submit,try to get the $_POST variables and then have a function that would return to you these values after verification process.just an idea though. Smile
#5

[eluser]cinewbie81[/eluser]
Hi,

I think you misunderstood my question ..
By default the gender dropdown menu has the value 'MALE' .. After i select and change it to 'FEMALE', then press 'F5' to refresh the page, it still giving me the value 'FEMALE'.. I want it to be 'Male' - the default value before user change anything on it ...
#6

[eluser]mistress_shiira[/eluser]
well i havent used the form helper also.Smile
can you try this:
Code:
?php    
    $options = array('Male'=> 0,'Female'=>1);
    echo form_dropdown('gender',$options,0);
?&gt;
#7

[eluser]cinewbie81[/eluser]
Hi,

It's the same result i get ..
the reason i have another extra parameter for form_dropdown is because i modify CI helper files.

See it's not only happen for form_dropdown, in fact other form element like form_input also the same ..
When i type something - let's say 'John' into the CustomerName field and press 'F5', the value 'John' is still there even after the Refresh key has been pressed .. It suppose to be blank isnt it ? I'm lost...
#8

[eluser]mistress_shiira[/eluser]
Code:
&lt;?php    
$options = array('0'  => 'Male','1'  => 'Female');
echo form_dropdown('gender', $options,'0');
?&gt;
this would just work for me...ive tried it..what is the other parameter for?
#9

[eluser]cinewbie81[/eluser]
The other parameter is for the 'id' ..
It just doesn't works for me..
do u mind to post your code here ? for both controller and view ?
#10

[eluser]mistress_shiira[/eluser]
oh shoot..Smile i dont what happened the first time i tried it..now when i retried,the dropdown box doesnt seem to work..
that doesnt work when i press F5 but when i highlight the address bar and hit Enter,it seems to work as you want.hmmm...




Theme © iAndrew 2016 - Forum software by © MyBB