Click to See Complete Forum and Search --> : Asp question
Michael Z.
10-12-2000, 12:51 PM
Hello, everybody. I am fairly new to Web development and ASP. My question
is as follows. I have a Select List Combo box on a form. When a user hits
submit button, the application goes thru a validation routine, and if there
are errors I need to be able to go back to original form and restore user's
original selection in the Select List. I figured out how to store selected
value in a variable or hidden form field, but how do I make the Select List
reflect the original selection. I hope this is clear enough. Any help or
suggestions would be greatly appreciated.
Puneet Mittal
10-12-2000, 03:07 PM
Hi ,
Maintain index numbers as values of items of list item.
for example
List Contains Items as
Apple value=1
Orange value=2
Bananas value=3
when you submit form then index value will be passed.
which you can store in hidden variable .
when original form with error is again displayed
set the index of list to that hidden variable
and you will get the selections as earlier selected.
Hope it helps
Bye
"Michael Z." <yz64@aol.com> wrote:
>
>Hello, everybody. I am fairly new to Web development and ASP. My question
>is as follows. I have a Select List Combo box on a form. When a user hits
>submit button, the application goes thru a validation routine, and if there
>are errors I need to be able to go back to original form and restore user's
>original selection in the Select List. I figured out how to store selected
>value in a variable or hidden form field, but how do I make the Select List
>reflect the original selection. I hope this is clear enough. Any help
or
>suggestions would be greatly appreciated.
Michael Z.
10-12-2000, 03:44 PM
Punneet, Thank you for your suggestion. Can you be more specific about how
would the Code look like using the index you are suggesting. Thanks.
"Puneet Mittal" <puneetmittal@usa.net> wrote:
>
>Hi ,
> Maintain index numbers as values of items of list item.
> for example
> List Contains Items as
>
>
> Apple value=1
> Orange value=2
> Bananas value=3
> when you submit form then index value will be passed.
> which you can store in hidden variable .
> when original form with error is again displayed
> set the index of list to that hidden variable
> and you will get the selections as earlier selected.
>
>Hope it helps
>Bye
>
>
>
>
>"Michael Z." <yz64@aol.com> wrote:
>>
>>Hello, everybody. I am fairly new to Web development and ASP. My question
>>is as follows. I have a Select List Combo box on a form. When a user
hits
>>submit button, the application goes thru a validation routine, and if there
>>are errors I need to be able to go back to original form and restore user's
>>original selection in the Select List. I figured out how to store selected
>>value in a variable or hidden form field, but how do I make the Select
List
>>reflect the original selection. I hope this is clear enough. Any help
>or
>>suggestions would be greatly appreciated.
>
Glenn
10-13-2000, 06:32 AM
Michael,
The bottom line is that you need to set the select object's selectedindex
property to the value of the variable or hidden field's value. When you
do this depends on how your code is currently written (whether you are building
your select (and all the option elements) from server-side script or client-side
script). Actually HOW you do it depends on that too. But I'll assume you
are doing it with client-side script. If so, the code would be something
like this:
sub window_onload()
whatever you need to do to determine if you've got to
reset your select to prev index (ie. errors found)...
mySelect.selectedIndex = "<%=serversidevariable%>"
OR
mySelect.selectedIndex = myhiddenfield.value
end sub
"Michael Z." <yz64@aol.com> wrote:
>
>Punneet, Thank you for your suggestion. Can you be more specific about
how
>would the Code look like using the index you are suggesting. Thanks.
>
>"Puneet Mittal" <puneetmittal@usa.net> wrote:
>>
>>Hi ,
>> Maintain index numbers as values of items of list item.
>> for example
>> List Contains Items as
>>
>>
>> Apple value=1
>> Orange value=2
>> Bananas value=3
>> when you submit form then index value will be passed.
>> which you can store in hidden variable .
>> when original form with error is again displayed
>> set the index of list to that hidden variable
>> and you will get the selections as earlier selected.
>>
>>Hope it helps
>>Bye
>>
>>
>>
>>
>>"Michael Z." <yz64@aol.com> wrote:
>>>
>>>Hello, everybody. I am fairly new to Web development and ASP. My question
>>>is as follows. I have a Select List Combo box on a form. When a user
>hits
>>>submit button, the application goes thru a validation routine, and if
there
>>>are errors I need to be able to go back to original form and restore user's
>>>original selection in the Select List. I figured out how to store selected
>>>value in a variable or hidden form field, but how do I make the Select
>List
>>>reflect the original selection. I hope this is clear enough. Any help
>>or
>>>suggestions would be greatly appreciated.
>>
>
James
01-22-2001, 11:49 AM
Hi Michael...
Try this:
In each of your select items, test to see if the Request.Form value mathces
the select item value. If it does, have the ASP write selected for that item.
<option value="MyValue" <% if Request.Form("MySelectionValue") = "MyValue"
then%>SELECTED<%end if%>>
Hope that addresses the problem, alternatively, you could try a client side
validation, which would avoid this situation outright.
-James
"Michael Z." <yz64@aol.com> wrote:
>
>Hello, everybody. I am fairly new to Web development and ASP. My question
>is as follows. I have a Select List Combo box on a form. When a user hits
>submit button, the application goes thru a validation routine, and if there
>are errors I need to be able to go back to original form and restore user's
>original selection in the Select List. I figured out how to store selected
>value in a variable or hidden form field, but how do I make the Select List
>reflect the original selection. I hope this is clear enough. Any help
or
>suggestions would be greatly appreciated.
devx.com
Copyright Internet.com Inc. All Rights Reserved