Forum Moderators: open
Does anyone have a hint of how to accomplish this?
Thanks
I don't have a complete answer to your problem (OK, so I haven't got it working yet!), but you will need to use Javascript to accomplish what you want. I would try adding an
id to the option like this: <form action="">
<select name="select">
<option value="" [b]id="choose"[/b]>Choose a city</option>
<option value="ny">New York</option>
<option value="bt">Boston</option>
<option value="at">Atlanta</option>
</select>
</form> Then try using
getElementById to change the display value to none, perhaps as an onclick event on the select element. Perhaps some of our Javascript gurus might have a better suggestion?
Kaled.
// Fills a form with parameters passed by url.
// The standard format is //..../page.html?name1=value1&name2=value2
// Parameters that are not recognised are ignored.
// Parameter names must correspond with element names in the form.
// Names are NOT case sensitive.
// Values are not case sensitive but case is preserved for text fields.
// To set or clear a checkbox, use name=1 or name=0 respectively.
// To set a radiogroup value, use name=value where value is the value of the button to be checked.function loadParam(f,p) // f is a form, p is a string : 'name=value'
{ var pa = p.split('='); if (pa.length < 2) return false;var n = pa[0].toLowerCase();
var v = pa[1].toLowerCase();
with (f) {
for (var i = 0; i < length; i++) with (elements[i]) {
if (n == name.toLowerCase()) {
var tp = type.toLowerCase();
if (tp == 'select-one') {
for (var j = 0; j < length; j++) if (options[j].text.toLowerCase() == v) {
selectedIndex = j;
break;
}}
else if ((tp == 'radio') && (value.toLowerCase() == v)) checked = true
else if (tp == 'checkbox') checked = ((v!= '') && (v.charAt(0)!= '0'))
else value = pa[1]
}}
}}function loadParams(f) // f is a form
{ var tmp = unescape(document.location.search); if (tmp.charAt(0) == '?') tmp = tmp.substring(1);if ((typeof(f) == 'undefined') ¦¦ (tmp == '')) return false;
tmp = tmp.split('&'); for (var i = 0; i < tmp.length; i++) loadParam(f,tmp[i]);
}loadParams(document.forms[0]);
<select name="gender_info">
<?php
$selected="";
if($_POST['gender_info']=="Mr.")
$selected="SELECTED";
echo "<option value=\"Mr.\"" . selected . ">";
echo "mr.";
echo "</option>\n";
$selected="";
if($_POST['gender_info']=="Mrs.")
$selected="SELECTED";
echo "<option value=\"Mrs.\"" . $selected . ">";
echo "mrs.";
echo "</option>\n";
?>
</select>