Ok, assuming you have an integer that you would pass in, you could loop
through all the elements in the field and check it's value.  Like such:

==============================

<HTML>
<HEAD>
<TITLE>Here's Your Answer, Mr. Decius...</TITLE>


</HEAD>

<script language="javascript">
<!--
 function autoSelect(strFormName, strFieldName, intLookupVal){
  var objForm = document.forms[strFormName]
  var objEl = objForm.elements[strFieldName]
  for(var x = 0; x< objEl.options.length; x++){
   if(parseInt(intLookupVal) == parseInt(objEl.options[x].value)){
    objEl.options[x].selected = true
   }
  }
 }
//-->
</script>

<BODY onLoad="autoSelect('myTestForm', 'myTestSelect', 1)">


<form name="myTestForm">

 <select name="myTestSelect">
  <option value="0">This will not be selected 1
  <option value="1">This will be selected
  <option value="2">This will not be selected 2
  <option value="3">This will not be selected 3
 </select>

</form>


</BODY>
</HTML>
==============================


I hope that helps, and I made it so you can even call it multiple times in a
row by throwing it into that function. All you need to know is the form
name,
field name and the option you want selected.

I must ask though - why go client-side? Can you guarantee that
their scripting is enabled?

Chris Tifer
http://www.emailajoke.com




----- Original Message -----
From: "LeGrand Decius" <[EMAIL PROTECTED]>
To: "ActiveServerPages" <[EMAIL PROTECTED]>
Sent: Friday, November 01, 2002 12:10 PM
Subject: Re: set listbox value selected


> Thanks for responding.
>
> I'm trying to do this with client-site Javascript.  I have achieve this
task
> with ASP but would rather do it with client-side javascripts.
>
>
> ----- Original Message -----
> From: "Chris Tifer" <[EMAIL PROTECTED]>
> To: "ActiveServerPages" <[EMAIL PROTECTED]>
> Sent: Friday, November 01, 2002 12:02 PM
> Subject: Re: set listbox value selected
>
>
> > Are you trying to do this with client-side JavaScript or with ASP since
> the
> > page submits to itself and you can determine it then?
> >
> > Chris Tifer
> >
> > ----- Original Message -----
> > From: "LeGrand Decius" <[EMAIL PROTECTED]>
> > To: "ActiveServerPages" <[EMAIL PROTECTED]>
> > Sent: Friday, November 01, 2002 11:54 AM
> > Subject: set listbox value selected
> >
> >
> > > Below I have a sample page with a listbox that submits to itself.
> > > How can I set the default selected value based on the previous
> selection?
> > > =================================================
> > > <html>
> > > <head>
> > > <title>Test</title>
> > > <meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
> > > <SCRIPT language=JavaScript>
> > > function getSelectedIndices (){
> > > var comboValue
> > > var selIndex = document.form1.selReports.selectedIndex;
> > > document.form1.sindex.value = selIndex;
> > > }
> > > </SCRIPT>
> > >
> > > </head>
> > >
> > > <body bgcolor="#FFFFFF" text="#000000">
> > > <form name="form1" method="post" action="Default_listbox.htm">
> > >   <p><select name="selReports" onChange="getSelectedIndices()">
> > >     <option value="0">Available Reports</option>
> > >     <option value="1">My Reports</option>
> > >     <option value="2">All Reports</option>
> > >   </select>
> > > </p>
> > >   <p>
> > >     <input type="submit" name="Submit" value="Submit">
> > >     <input type="hidden" name="sindex">
> > >   </p>
> > > </form>
> > > </body>
> > > </html>
> > >
> > >
> > >
> > > ---
> > > You are currently subscribed to activeserverpages as:
[EMAIL PROTECTED]
> > > To unsubscribe send a blank email to
> > %%email.unsub%%
> > >
> >
> >
> > ---
> > You are currently subscribed to activeserverpages as:
> [EMAIL PROTECTED]
> > To unsubscribe send a blank email to
> %%email.unsub%%
> >
>
>
> ---
> You are currently subscribed to activeserverpages as: [EMAIL PROTECTED]
> To unsubscribe send a blank email to
%%email.unsub%%


---
You are currently subscribed to activeserverpages as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]

Reply via email to