PDA

Click to See Complete Forum and Search --> : Please Help with Form Object problem


dvst8
Jul 10th, 2000, 10:32 AM
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:



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:



<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

Mark Sreeves
Jul 10th, 2000, 03:32 PM
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!



<%@ 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!)

dvst8
Jul 11th, 2000, 09:04 AM
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