Results 1 to 3 of 3

Thread: Please Help with Form Object problem

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2000
    Posts
    142
    I'm building a web page that has a form. The values of the Form Fields are populated by some ASP statements on page load.

    I have an onclick event that grabs the values out of this form and populates another form with the same values.

    When the javascript event handler runs, I get the following error:


    Code:
    document.myform1.num1 is not an object
    This struck me as strange, so I investigated, and noticed that my Script Editor doesn't pick up my form objects as objects either. I figured out that the reason this is happening is because I define the value of the field with
    ASP as follows:


    Code:
    <input type="text" name="num1" value="<%=oRS("Source")%>">
    If I take out the ASP <%..%> the Script Editor WILL recognize num1 as a Form Object, but with the ASP it DOES NOT!

    Has anyone encountered this sort of problem before? How can I get around it?

    Thanks

    dvst8
    Secret to long life:
    Keep breathing as long as possible.

  2. #2
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    It's hard to tell what the problem is without seeing the whole script but I suspect that it might be a scope problem.

    Where on the page have you got the Javascript?

    This works OK (for me anyway)

    I don't know what it looks like in Interdev because I wrote it using notepad!

    Code:
    <%@ Language=VBScript %>
    <HTML>
    <HEAD>
    <!--
    Written by Mark Sreeves
    -->
    <script language='Javascript'>
    function doIt(){
    
    document.myform2.num2.value=document.myform1.num1.value;
    
    }
    
    </script>
    </HEAD>
    
    <BODY>
    <%
    
    	dim conn
    	dim rst
    	dim strSQL
    
    	Set Conn = Server.CreateObject("ADODB.Connection")
    	
    	strSQL = "SELECT * FROM table2;"
    
    	Conn.Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=C:\lenin.mdb")
    
    	Set rst = Conn.Execute(strSQL)
    	rst.movefirst
    %>
    	
    <form name=myform1>
    	<input type="text" name="num1" value="<%=rst("List2")%>">
    	<input type=button onClick="doIt()">
               
    </form>   
    <form name=myform2>
    	<input type="text" name="num2">
               
    </form>  
    
    
    
     </BODY>
    </HTML>
    (OK, so I confess based it on a script from yesterday!)
    Mark
    -------------------

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    May 2000
    Posts
    142
    thanks for the response mark.

    i finally figured it out.... it was sorta a scope issue..

    i noticed i was trying to nest forms... which is not a good idea!!

    /dvst8
    Secret to long life:
    Keep breathing as long as possible.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width