Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics 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 June 18th, 2004, 12:59 AM
Registered User
 
Join Date: Jun 2004
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default .NET and JavaScript Forms

Is there a new way to reference forms and elements in javascript when using .net?

My code that works in html, but when I try in .NET, I get an error that says: 'document.forms[...].elements' is null or not an object

Anyone know why this is happening?

Here's my html code:

<html>
<head>

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function formHandler(){

var selectValues = new Array();
    for ( var j = 1; j <= 10; ++j ){

        var sel = document.forms["B"+j].elements["C"+j];
        selectValues[j] = sel.options[sel.selectedIndex].value;

            if(selectValues[j] != ""){
                window.open(selectValues[j], "_self");
            }
    }
}



// End -->
</SCRIPT>

</head>
<body>

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin

    for ( var j = 1; j <= 10; ++j ){
        document.writeln('<form method="POST" action="#" name="B' + j + '"style="margin-bottom:2; margin-top:2;">')
        document.writeln('<select name="C' + j +'" size=1 onChange="javascript:formHandler()">')
        document.writeln('<option selected value="">-- Select a Link --</option>')
        document.writeln('<option value="#?page=1&id=' + j + '">Page 1</option>')
        document.writeln('<option value="#?page=2&id=' + j + '">Page 2</option>')
        document.writeln('<option value="#?page=3&id=' + j + '">Page 3</option>')
        document.writeln('</select>')
        document.writeln('</form>')
    }

// End -->
</SCRIPT>

</body>
</html>
 
Old June 18th, 2004, 08:12 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Do you have a book on ASP.NET? It sounds like you need an introduction to ASP.NET web forms. I would suggest any of the "Beginning ASP.NET with ..." wrox books. Just pick your language (VB.NET or C#.NET).
 
Old June 18th, 2004, 11:10 AM
Registered User
 
Join Date: Jun 2004
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes, I have 4 books; however I lent them to someone for the week :-) Great timing I know...

Any ideas?
 
Old June 19th, 2004, 10:07 AM
Friend of Wrox
Points: 3,558, Level: 25
Points: 3,558, Level: 25 Points: 3,558, Level: 25 Points: 3,558, Level: 25
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: California, USA
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

where do u get error from?! & What?!
do u know what I think?! in ur ASP.NET page u have <form> but u have NOT it here.
Check it & keep in touch...

Always:),
Hovik Melkomian.
 
Old June 19th, 2004, 10:11 AM
Friend of Wrox
Points: 3,558, Level: 25
Points: 3,558, Level: 25 Points: 3,558, Level: 25 Points: 3,558, Level: 25
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: California, USA
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

Oops! Sorry! I didnt see ur genrated tags!!
OK u posted ur HTML page, can u post ur ASP.NET page.

Always:),
Hovik Melkomian.
 
Old June 19th, 2004, 10:37 AM
Registered User
 
Join Date: Jun 2004
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The problem was i had nested forms, and I didnt realize it. html doesnt' allow nested forms, so when i saw the first form it didnt recognize the rest, hince the error.





Similar Threads
Thread Thread Starter Forum Replies Last Post
manipulating forms with php and javascript Hylsan Beginning PHP 0 April 20th, 2007 09:11 AM
Acrobat forms with Javascript tdmpatio Java Basics 1 March 28th, 2006 05:00 AM
Working with Forms and Date in Javascript danieljava Pro JSP 1 January 16th, 2006 05:56 AM





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