Welcome Guest, Not a member yet? Register   Sign In
validation problem with Dropdoen list
#1

[eluser]Ram2810[/eluser]
Am trying to retain the value on postback if error occurs in the form .... when valiadtion fails i want the page should show the previous selected drop down value ... i followed as noted in user guide but there is no proper out put .... pls help me out ....

THE CODE
Code:
<form action="<?= base_url();?>users/registersubmit" method="post">
&lt;?php echo validation_errors('<p class="error">','</p>'); ?&gt;
<fieldset>
<legend><span>Login&nbsp;Credentials</span></legend>
<ol><li>
<label for="u_regtype" >Type of Registration</label>
<select id="u_regtype" name="u_regtype">
&lt;?php foreach ($regtypes as $regtype){
echo "<option value='".$regtype->id."'";echo set_select('u_regtype',$regtype->id).">".$regtype->rgt_name."</option>";}?&gt;  
</select>
</li><li>
<label for="u_username">User Name:<span class="require"><img src="&lt;?=asset_url()?&gt;css/design_images/required_star.gif" alt="required" /></span> </label>
&lt;input id="u_username" name="u_username" value = "&lt;?= set_value('u_username');?&gt;" class="text" type="text" /&gt;
</li><li>
<label for="u_pass">Password:<span class="require"><img src="&lt;?=asset_url()?&gt;css/design_images/required_star.gif" alt="required" /></span> </label>
&lt;input id="u_pass" name="u_pass" class="text" type="text" /&gt;
</li><li>
<label for="u_pass2">Re-enter Password:<span class="require"><img src="&lt;?=asset_url()?&gt;css/design_images/required_star.gif" alt="required" /></span> </label>
&lt;input id="u_pass2" name="u_pass2" class="text" type="text" /&gt;
</li></ol></fieldset>&lt;/form&gt;

I am not able to select the previous selected on returning to same page after producing errors
#2

[eluser]LuckyFella73[/eluser]
I think your option tag has kind of a typo. Should look like:
Code:
<select id="u_regtype" name="u_regtype">
&lt;?php foreach ($regtypes as $regtype){ ?&gt;
    <option value="&lt;?php echo $regtype->id; ?&gt;" &lt;?php echo set_select('u_regtype',$regtype->id);?&gt; >&lt;?php echo $regtype->rgt_name; ?&gt;</option>
&lt;?php } ?&gt;
</select>
#3

[eluser]Ram2810[/eluser]
When i submit the page with errors the page will repopulate with error messages and the fields will be populated with values entered before the page is submitted .... but the dropdown list value is not the one that i selected... it is showing default value once again. How can i make the already selected value once aging after postback?
#4

[eluser]LuckyFella73[/eluser]
Hmm, it should ...

Are you sure you did set up a rule for the dropdown element?
Otherwise the selected item won't be repopulated.
In case you don't really need a rule just set a rule like "TRIM".




Theme © iAndrew 2016 - Forum software by © MyBB