i have a form with listbox in it.i want to use the OnSubmit event on this
form . something like OnSubmit=<%if Request.form("ListboxName")= 0 then
call verify end if%>..why does this line of code does not seem to
execute..is there anything wrong...can i refer to the listbox as
Request.form("ListBoxName")?
I do not think you have grasped the ASP page life cycle.
1) OnSubmit is a client side JavaScript event
2) if Request.form("ListboxName... is Server Side VBScript.
Request.form("ListboxName") is obviously empty when the page is first
processed.
the client side code that renders will be somthing like:
OnSubmit=""
your "verify" function will never get called.. (I hope you didn't spend
too much time writing that one ;) )
which will cause nothing to happen.
You must access the drop downlist contents using the DOM (document object
model) through client side javascript not through server side code (I
wonder if you have been programming ASP.NET and are now getting confused
with old fashioned ASP..?).
Anyway the code you need is somthing along the lines of:
<... onSubmit="return(CheckList(document.all.myForm))"
Then write a function to check the contents client side:
function CheckList(oForm){
var errMsg = 'Fill it all in!';
if (oForm.yourDropDownListName....
If the DOM is new to you then check out the very useful DOM viewer which
can be found on http://www.brainjar.com/ this will conceptually help you
understand the properties etc. Also check out the MSDN DHTML ref.
In the mean time having read some of your other questions on this
newsgroup I would highly recommend, the WROX Beginning Active ServerPages
and perhaps the Professional JavaScript book as well.
Happy coding bro.
> i have a form with listbox in it.i want to use the OnSubmit event on
this
> form . something like OnSubmit=<%if Request.form("ListboxName")= 0 then
> call verify end if%>..why does this line of code does not seem to
> execute..is there anything wrong...can i refer to the listbox as
> Request.form("ListBoxName")?