A preselect dropdown routine not working with database

C

Chuck

I'm using a bit of Javascript to pre-select the Select
item from a dropdown, based on the user's previous
choice, and it worked fine as long as I was just posting
to "other", but it won't work on posts to my database.
It just returns the default rather than the previously
selected choice. Here's the code in question:

<%itemToSelect = request.form("Center")%>

<script type "text/javascript"><!--
function PreselectMyItem(itemToSelect)
{
var mydropdown = document.forms(0).Center;
for (i = 0; i < mydropdown.options.length; i++)
{
if mydropdown.options.value == itemToSelect)
{
mydropdown.options.sselected=true;
break;
}
}
}
--></script>

<body onload="PreselectMyItem('<%=itemToSelect%>')">

Then the form method is a post to the database (set up by
FP). I do have the form calling to itself in place of
the confirmation page, but even with the default confirm
page it still doesn't work once the database is involved.

Any ideas what's going on would be appreciated.

Thanks.
Chuck
 
M

MD Websunlimited

When you have the database involved the output is created by the Smart HTML and streamed to the browser. Therefore, it is not
interrupted by ASP scripting and the itemToSelect is never set.
 
C

Chuck

So does that mean that what I'm trying to do is
impossible?

Chuck
-----Original Message-----
When you have the database involved the output is
created by the Smart HTML and streamed to the browser.
Therefore, it is not
interrupted by ASP scripting and the itemToSelect is never set.

--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 Released Special Pricing
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible

"Chuck" <[email protected]> wrote in
message news:[email protected]...
I'm using a bit of Javascript to pre-select the Select
item from a dropdown, based on the user's previous
choice, and it worked fine as long as I was just posting
to "other", but it won't work on posts to my database.
It just returns the default rather than the previously
selected choice. Here's the code in question:

<%itemToSelect = request.form("Center")%>

<script type "text/javascript"><!--
function PreselectMyItem(itemToSelect)
{
var mydropdown = document.forms(0).Center;
for (i = 0; i < mydropdown.options.length; i++)
{
if mydropdown.options.value == itemToSelect)
{
mydropdown.options.sselected=true;
break;
}
}
}
--></script>

<body onload="PreselectMyItem('<%=itemToSelect%>')">

Then the form method is a post to the database (set up by
FP). I do have the form calling to itself in place of
the confirmation page, but even with the default confirm
page it still doesn't work once the database is involved.

Any ideas what's going on would be appreciated.

Thanks.
Chuck



.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top