navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

 

Form with ASP, Javascript and Loops

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP and Database >> Form with ASP, Javascript and Loops
Page: [1]
 
HW15

 

Posts: 57
Joined: 3/12/2004
Status: offline

 
Form with ASP, Javascript and Loops - 8/14/2008 0:54:43   
Hello,

I spent way to many hours trying to figure this out... so I wanted to share the solution in hopes of saving others from wasting their time.

Using an ASP loop, we display a table with many rows, each containing a form inside a div. Thus, we have multiple divs on the page, each containing a form.

Furthermore, each div is displayed with a show/hide Javascript function that displays the div when called by clicking a link. Thus, each form is only visible when the appropriate link is clicked. (Code not included here)

Since each div uses this show/hide function they each need a unique div ID so the function knows which div to target.

This is our div containing a form:

<div id="<% =myASPdynamicValue %>">
<form name="myFormName" method="post" action="myProcessingPage.asp">
<input type="text" name="phoneNumber" value="<% =myASPdynamicValue %>
</form>
</div>


Then we use a link instead of a button to submit the form with Javascript.

<a href="javascript:document.myFormName.submit();">Submit</a>


Here is where the glitch came in... the form would not submit! The wild goose chase began with the question does a form work inside a div? Even a hidden div? What about the javascript submit link, does it work when a form is inside a div that has an ID? And on and on. The answers are yes.

Then why does the form submit properly when placed at the top or bottom of my page, but not when placed inside the div?

Finally, the solution is revealed... the form was inside a loop! As I mentioned before, there are multiple divs that each contain a form. Each div was given a unique ID <% =myASPdynamicValue %>. Similarly, each form must be given a unique name as well.

<form name="<% =myASPDynamicValue %>">

The lesson is that each form must have unique name, especially when used inside a loop. Most of you probably already knew this! I wanted to share just in case.

Happy Coding!




Thumbnail Image
:)

Attachment (1)
ou812

 

Posts: 1601
Joined: 1/5/2002
From: San Diego
Status: offline

 
RE: Form with ASP, Javascript and Loops - 8/14/2008 1:37:48   
Thanks for sharing HW15!

For those of us who did know it, it is always nice for a reminder. And, of course, for those who didn't, this will be a big trouble shooting time saver!

_____________________________

-brian

EnterpriseDB: Enterprise-class relational database management system
PostgreSQL: The world's most advanced open source database

(in reply to HW15)
Page:   [1]

All Forums >> Web Development >> ASP and Database >> Form with ASP, Javascript and Loops
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts