Wrox Programmer Forums
|
ASP Forms As of Oct 5, 2005, this forum is now locked. Please use "Classic ASP beginner" at http://p2p.wrox.com/forum.asp?FORUM_ID=54 or "Classic ASP Professional" http://p2p.wrox.com/forum.asp?FORUM_ID=56 instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Forms 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 August 5th, 2003, 09:12 AM
Registered User
 
Join Date: Jul 2003
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Javascript Validations

Hi people,
    I have writtem some code so that after a person has clicked on 2 selections in 2 different select lists, the submit button appears at teh bottom of the form,I am attempting to now make the submit button only appear after a further text areas on teh form has been filled in and I can't do it. here is the code

html>
<head>
<TITLE>Category and Subcategory Drop Down Lists Demonstration</TITLE>
<title>Inputting a new Question</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<SCRIPT Language="JavaScript">
 function lawChanged()
  {
   if(form1.LawSelect.selectedIndex==0){ alert("You must choose a Law")}
   else
    {
     form1.action="http://pertinax.cms.shu.ac.uk/mmtec/mm32/HughInputAQuestion1b.asp"
     form1.submit()
    }
  }

 function mySubmit()
  {
   somethingWrong=false
   if(form1.ComponentSelect.selectedIndex==0)
     {
       alert("You must choose a Component")
       somethingWrong=true
     }
  if(form1.LawSelect.selectedIndex==0)
    {
     alert("You must choose a Law")
     somethingWrong=true
     }
  if(form1.questionText.value="")
           {
        alert("You must choose a Component")
        somethingWrong=true
     }
   if (!somethingWrong)
    {
     alert("LawNo selected =" + form1.LawSelect.selectedIndex + " and component selected is " + form1.ComponentSelect.selectedIndex)
     astring="http://pertinax.cms.shu.ac.uk/mmtec/mm32/HughInputAQuestion2.asp?LawNo=" + form1.LawSelect.selectedIndex+"&ComponentNo=" + form1.ComponentSelect.selectedIndex
     alert("Am calling " + astring)
     form1.action= astring
     document.all.Submit.style.visibility='visible'
    }
  }
  function ComponentChanged()
  {
   if(form1.ComponentSelect.selectedIndex==0)
           { alert("You must choose a Component")
        }
   }
</SCRIPT>
</head>

<body>
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
   HaveChosen=False
   Set MyConn=Server.CreateObject("ADODB.Connection")
   Set Rs=Server.CreateObject("ADODB.RecordSet")
   Set Rs2=Server.CreateObject("ADODB.RecordSet")
   MyConn.Open("mm32")
   Rs.Open "SELECT * From Law ORDER by lawNo", MyConn, 1, 2
   LawChosen=Request.Form("LawSelect")
   If Not IsNull(LawChosen) Then
    LawChosen=Cint(LawChosen)
    SQLString="SELECT * From Component WHERE lawNo=" & LawChosen
    Rs2.Open SQLString, MyConn, 1, 2
    HaveChosen=True
   End If


  Response.write("")
  Response.write("<P>")
  Response.write("<P>")
  Response.write("First Select a Law<P>")
  Response.write("<form name='form1' method='post' >")

  Response.write("<SELECT Name='LawSelect' SINGLE size=10 onChange='lawChanged()'> ")
  Response.write("<OPTION Value='NONE'>--Choose a Law--")

    While NOT Rs.EOF
      astring="<OPTION VALUE=" & Rs("lawNo")
    If Rs("lawNo") = LawChosen Then
       astring=astring & " SELECTED"
      End if
     Response.write(astring & ">" & Rs("lawNo") & ". " & Rs("lawText"))
     Rs.MoveNext
    WEND

  Response.write("</SELECT>")
  If HaveChosen Then
    Response.write("<SELECT Name='ComponentSelect' SINGLE size=10 onChange='ComponentChanged()' > ")
    Response.write("<OPTION Value='NONE'>--Choose a Component--")
     While NOT Rs2.EOF
      astring="<OPTION VALUE=" & Rs2("componentNo") & ">" & Rs2("componentNo") & ". " & Mid(Rs2("componentText"),1,30)
      Response.write( astring & "<BR>")
      Rs2.MoveNext
     WEND
    Response.write("</SELECT>")
 End If
 %>

All our questions are going to be multiple choice so please tap your question in here.Please dont make it a question that yields a yes/no answer<br>
<textarea cols = 100 rows =2 name=questionText wrap=hard></textarea><br>
<%
   Response.write("<p>")
   Response.write(" <input type='submit' name='Submit' value='Submit' onClick='mySubmit()' STYLE='visibility:hidden'>")
   Response.write("</p>")
  Response.write("</form>")
  Response.write("<p><strong></strong> </p>")
%>
</body>
</html>
I would be so grateful if you could help

andrew





Similar Threads
Thread Thread Starter Forum Replies Last Post
Textbox Validations using javascript jithendar84 ASP.NET 1.0 and 1.1 Basics 2 January 18th, 2008 03:12 PM
Validations in dataGrid p2pMember ASP.NET 1.0 and 1.1 Basics 1 December 7th, 2005 08:17 PM
problem with validations ashokparchuri General .NET 1 April 14th, 2005 08:20 AM
Validations... Flunders Beginning VB 6 3 September 29th, 2004 07:09 AM
Validations not working Ajay Jain ASP.NET 1.0 and 1.1 Basics 1 February 24th, 2004 01:16 PM





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