0

Hi all -

How can i echo back the value of of the following -

If the form has other errors - ie. if a user has missed filling in a field -
I can echo other fields if there are errors
Im just having some difficulties in echo-ing out the value selected from the drop down box -

Any pointers or advice would be appreciated - :)
error trapping

//trade experience
	if ( strlen( $tskl ) < 1 ) 
	{ 
		$msg_tskl = '<img src="img/loading.gif" width="16" height="16" 
		hspace="2" vspace="2" align="left" title="Select trade or service" alt="Select trade or service" />
		<font color="#21699e" size="-3">&nbsp;&nbsp;Select trade or service</font>';
		$b1=false;
	}

here is the part of the form - its a drop down box that is automatically populated from a mysql database -

<select name="wex" value='<? echo $experience; ?>' class="ta" id="wex">
                            <option value="">Select experience</option>
                            <?
                                 while($category_arr = mysql_fetch_array($result_wex)){
                                     ?>
                                     <option value="<?=$category_arr['experience']?>"><?=$category_arr['experience']?></option>
                                     <?
                                 }
                            
                            ?>
                    </select>
3
Contributors
6
Replies
7
Views
6 Years
Discussion Span
Last Post by vibhaJ
0

sorry here is the correct part of my error checking

//trade experience
	if ( strlen( $wex ) < 1 ) 
	{ 
		$msg_wex = '<img src="img/loading.gif" width="16" height="16" 
		hspace="2" vspace="2" align="left" title="Select you experience in years" alt="Select you experience in years" />
		<font color="#21699e" size="-3">&nbsp;&nbsp;Select your experience in years</font>';
		$b1=false;
	}
0
<select name="wex" value='<? echo $experience; ?>' class="ta" id="wex">

why you printing value in select box? with

value='<? echo $experience; ?>'

there is not value attr in select tag

0

'select' tag can not have value.
Value is only for 'option'.
When form is submitted add this php code to debug it.
echo $_POST; exit;

0

hi thanks for all your help -

but everytime i submit the form all data slected is removed -
at the top of the form I have the following to populate each dropdown box -

$result_trade = mysql_query("select field from tblname ");

When i select a trade and submit the form, if there are validation error, the drop down box is not holding the value ?

Any ideas why this is happening

0

Use this code to remain selected last value.

<option <?=($_REQUEST['wex']==$category_arr['experience'])?('selected'):('');?> value="<?=$category_arr['experience']?>"><?=$category_arr['experience']?></option>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.