Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 10th, 2006, 06:07 AM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default What have I missed??

Im sure i have done this before. Looks like it should work to me, would apreciate some assistance. My objective is to name and validate a form using the word assess & <%= getInfo(0) %> which is a unique number (yes there are multiple forms on the page, would like it to remain so)

The form tag is:

<form name="assess<%= getInfo(0) %>" method="post" action="<%= URLBase %>assess.asp" onSubmit="return val('assess<%= getFics(0) %>');">

When I view source I get

<form name="assess1" method="post" action="http://localhost/MHQ-MC/assess.asp" onSubmit="return val('assess1');">

This calls the following JS function:

  function val(formName)
  {
     if(document.formName.oAssess.selectedIndex==0)
     {
    alert("You must...");
    document.formName.oAssess.focus();
    return(false);
     }
     return(true);

  }

The above function fails to enter the if condition if no selection has been made. The value is being passed, I can alert this no problem using alert("formName"); in the above function. The problem is in the function and not before, I know this also because this works fine:

  function val(formName)
  {
     if(document.assess1.oAssess.selectedIndex==0)
     {
    alert("You must...");
    document.assess1.oAssess.focus();
    return(false);
     }
     return(true);

  }

Is what I am trying to do possible? Im sure it is and hope I have missed something.

TYIA

Wind is your friend
Matt
__________________
Wind is your friend
Matt
 
Old February 10th, 2006, 06:30 AM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , United Kingdom.
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Matt,

I think it should work if you reference your fields using:
Code:
document.forms[formName].oAssess
instead of
Code:
document.formName.oAssess
HTH,

Chris

 
Old February 10th, 2006, 07:53 AM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

Hello there

I havnt used this syntax before. Thanking you kindley it works a treat.

Wind is your friend
Matt




Similar Threads
Thread Thread Starter Forum Replies Last Post
Should have been easy to see, but I missed it! Dwayne BOOK: Beginning Microsoft Visual Basic 2008 ISBN: 978-0-470-19134-7 2 March 25th, 2009 12:52 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.