Click to See Complete Forum and Search --> : Rememebring drop down values when submitting a form


zonome
05-01-2003, 05:03 AM
I have a web page where the user can select values from a drop down list. Then depending on what they select I submit the form and display a table to them. The table itself contains another drop down list that allows the user to select from a list of values. Once again depending on what they choose from the second list the form gets submitted and they are presented with another table. The problem I am having is that the second time I submit the form it seems that the value the user selected from the first drop down list is lost and instead replace by the last item on the list from the first drop down. How do I remember the value the user has selected from the first drop down box so that it is not lost when the form is submitted the second time?

Here are my Java Script functions...I can not submit more than this as the message will get too long

function submitSelectedCurrency(){
var currencyListLength = document.curveSourceForm.CurrencyList.length
for (var i = 0; i < currencyListLength;i++){
if ( document.curveSourceForm.CurrencyList.options[i].selected == true){
document.curveSourceForm.userSelectedCurrency.value = document.curveSourceForm.CurrencyList.options[i].text;
document.curveSourceForm.userSelectedBook.value = document.curveSourceForm.BookList.options[document.curveSourceForm.BookList.selectedIndex].text;

}
}
document.curveSourceForm.submit();
}

function submitSelectedCurveSource(){
var currencyListLength = document.curveSourceForm.CurrencyList.length
for (var i = 0; i < currencyListLength;i++){
document.curveSourceForm.userSelectedSource.value = document.curveSourceForm.CurveSourceList.options[document.curveSourceForm.CurveSourceList.selectedIndex].text;
document.curveSourceForm.displayedAlready.value = "yes"
document.curveSourceForm.userSelectedBook.value = document.curveSourceForm.BookList.options[document.curveSourceForm.BookList.selectedIndex].text;
document.curveSourceForm.userSelectedCurrency.value = document.curveSourceForm.CurrencyList.options[i].text;

}
document.curveSourceForm.submit();
}

function callServlet(){
document.curveSourceForm.action="/priceEngineReport/curveSource/curveSourceConfig";
for (var i = 0; i < currencyListLength;i++){
document.curveSourceForm.userSelectedSource.value = document.curveSourceForm.CurveSourceList.options[document.curveSourceForm.CurveSourceList.selectedIndex].text;
document.curveSourceForm.userSelectedBook.value = document.curveSourceForm.BookList.options[document.curveSourceForm.BookList.selectedIndex].text;
document.curveSourceForm.userSelectedCurrency.value = document.curveSourceForm.CurrencyList.options[i].text;
}
document.curveSourceForm.submit();
}

gil davis
05-01-2003, 05:46 AM
I can not submit more than this as the message will get too longOne of the many, many reasons why we prefer a link to your page. In lieu of a link, you can zip your page and any other necessary files together and attach the zip file to your post. See the "Attach file:" part of the form, below the options.

zonome
05-01-2003, 06:04 AM
Sorry.. I can not include a link as the page sits on the company's intranet and hence inaccessible. But I will send the HTML page that contains the code. I did not realise you could do that...... :-|

zonome
05-01-2003, 06:42 AM
Is there any way I can hold a user's choice from a drop down box so that when the page is refreshed or the form is submitted I can still display what the user selected initially?

I know I have to do something along these lines....

document.curveSourceForm.CurrencyList.selected = document.curveSourceForm.CurrencyList.options[i].text;

but this does not seem to be working!

zonome
05-01-2003, 07:38 AM
Is this what you mean?

var curlist = document.curveSource.CurrencyList
for( var i=0;i< curlist.length;i++){
if(curlist.options[i].selected)
curlist.options[i].selected = curlist.options [curlist.selectedIndex].text
}

I have tried it but it does not work!

Does this retain the value that the user has selected from teh drop down list after the form has been submitted to itself?

zonome
05-01-2003, 09:02 AM
The form gets submitted 3 times. Twice to iself and the last time it calls a servlet in the action part of the FORM when the users click on a submit button. I need to collect and retain all the values that are generated when the form is submitted to itself so that I can pass those on to my servlet.

Is it not possible to hold on to each of these values after each submit?