jayce
September 23rd, 2005, 04:07 PM
hi there,
The way I proceed is to check my form thru PHP, so I submit the form and with PHP I check if all values have been entered/selected. If somehting is wrong I redisplay the form with the values previously entered/selected
so far my code works perfectly except to display the values from an exisiting arrays
but I would like to improve it in order to know which line(item) was selected after before the post.
So would you have an idea on how to know which line was selected before the post or my select fields ?
Please advise. Thanks,
<script type="text/javascript" language="Javascript">
var countryCode = new Array("","country01","country02","country03");
var countryDesc = new Array("","AUSTRALIA","UNITED KINGDOM","UNITED STATES");
function DisplayParentValues() {
var maxValues=0;
var listValues = document.myForm.country;
maxValues = countryCode.length; //matching the number of lines of this countrycode array
listValues.options.length = 0; // reset previous values in the select form
for (items=0; items<maxValues; items++){
listValues.options[listValues.options.length] = new Option(countryDesc[items],countryCode[items]); //populates the select list with country code and description
}
}
</script>
<body>
<form name="myForm" method="post">
....
<input tyep="text" name="myfield" value="<?php echo $_POST['myfield']?>">
<select name="country" ><script>DisplayParentValues('service');</script> </select>
...
<input type="submit" value="submit" >
</form>
</body>
The way I proceed is to check my form thru PHP, so I submit the form and with PHP I check if all values have been entered/selected. If somehting is wrong I redisplay the form with the values previously entered/selected
so far my code works perfectly except to display the values from an exisiting arrays
but I would like to improve it in order to know which line(item) was selected after before the post.
So would you have an idea on how to know which line was selected before the post or my select fields ?
Please advise. Thanks,
<script type="text/javascript" language="Javascript">
var countryCode = new Array("","country01","country02","country03");
var countryDesc = new Array("","AUSTRALIA","UNITED KINGDOM","UNITED STATES");
function DisplayParentValues() {
var maxValues=0;
var listValues = document.myForm.country;
maxValues = countryCode.length; //matching the number of lines of this countrycode array
listValues.options.length = 0; // reset previous values in the select form
for (items=0; items<maxValues; items++){
listValues.options[listValues.options.length] = new Option(countryDesc[items],countryCode[items]); //populates the select list with country code and description
}
}
</script>
<body>
<form name="myForm" method="post">
....
<input tyep="text" name="myfield" value="<?php echo $_POST['myfield']?>">
<select name="country" ><script>DisplayParentValues('service');</script> </select>
...
<input type="submit" value="submit" >
</form>
</body>