Dear all,
Do you have any idea on move a text box value to list box.
Store text box value into list box and I wish to save list box value to database.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>add to dropdown</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript">
window.onload=function() {
document.forms['form1'].fruit.onblur=function(){addToDD(this.value);};
}
function addToDD(val) {
var oSelect=document.forms['form1'].select1;
oSelect.options[oSelect.options.length]=new Option(val, val);
document.forms['form1'].fruit.value="";
}
</script>
</head>
<body>
<form action="#" name="form1">
<fieldset><legend>add to dropdown</legend>
<select name="select1">
<option>apple</option>
<option>banana</option>
<option>cranberry</option>
</select>
<label>add text: <input type="text" name="fruit"></label>
</fieldset>
</form>
</body>
</html>
Example found in Internet. I do not think this will work because after refresh, all value in drop down has gone. Isn't I need to include $_SESSION['arr'] = array();
$_SESSION['arr'][] = $_POST['text_name'];
Language: php and javascript
Please advise. Thanks.
JavaScript Text box value move to list box