?
Solved

JSP form association

Posted on 2005-05-11
6
Medium Priority
?
313 Views
Last Modified: 2010-04-01
At the top of this JSP page it has

....
<form name="check" ....></form>
<form name="tran" ....></form>

I don't understand having two forms in a JSP.  Which form is assoicated with the events.

Like later on in the code I have an drop down box, how do I know which form it's associated with if I wanted to access it using JavaScript.
0
Comment
Question by:corduroy9
  • 4
  • 2
6 Comments
 
LVL 29

Expert Comment

by:bloodredsun
ID: 13980150
while it's possible to have two forms in a page, normally they have two different uses, e.g. a search form and a login form on the same page. The submission will be controlled by either a button in the form (between the <form> tags) or an on click handler in javascript.

The elements in between the start and closing form tags tell you what is associated with each individual form

The "action" attribute of the form tells you where the form is being sent to when it is submitted.

>>Like later on in the code I have an drop down box, how do I know which form it's associated with if I wanted to access it using JavaScript.

If it's outside of the form tags then it associated with neither.

Post the code and I can help you further.
0
 
LVL 2

Author Comment

by:corduroy9
ID: 13980190
Well its a bunch of code so I'm not going to post it all.... but I think you pointing me on the right track.  

Right now I have a jsp page that has this at the very top

<form name="check" ....></form>
<form name="tran" ....></form>

Then further down the line I have in a table I have

<SELECT name = "list" onclick="transfer(this");">

So in the function transfer if I wanted control of the list drop down so I could add 'options' to it how would I access it.

document.list.options ??



... Also the action attrubite for both the forms just say "default".  Does this mean its getting sent back to itself?
0
 
LVL 29

Expert Comment

by:bloodredsun
ID: 13980326
Sorry but not much of this makes sense...

>><form name="check" ....></form>
>><form name="tran" ....></form>

This is fine, you have two forms

>>Then further down the line I have in a table I have
>><SELECT name = "list" onclick="transfer(this");">

This will do nothing if it's not inside another form (and also the javascript is malformed: too many quotes)
have a look here http://www.javascriptkit.com/jsref/select.shtml on how to access the select element using javascript.

>>Also the action attrubite for both the forms just say "default".  Does this mean its getting sent back to itself?
Nope. It means that the form is being sent to a page/servlet/whatever called "default" in the same directory as the page that the form is in. If you want it sent to itself do this: action="#"

Are you using any JSP in this or is it all HTML and JavaScript. If it's just HTML and JavaScript, how comforatble are you playing with this type of code?


0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 29

Expert Comment

by:bloodredsun
ID: 13980435
If you're not sure of your HTML and JavaScript then I suggest that you go here http://www.htmlgoodies.com. It's a great ste that will teach you all you need to know about HTML an JavaScript, including forms and onClick handlers (often classes under DHTML).

Is this code that you have written or is it from someone else?
0
 
LVL 2

Author Comment

by:corduroy9
ID: 13980443
No its a JSP page.  I'll give you the structure.

taglibs...

<HEAD>
<script type="text/javascript">

Javascript functions

</script

...
...

</HEAD>

<BODY class = stuff>
<form name="check" ....></form>
<form name="tran" ....></form>

<table
...
...
   <td ....><SELECT name = "list" onclick="transfer(this);">

....

</table>
</body>
</html:html>


Now my question is there is no way to access the select dropdown in those javascript functions above?
0
 
LVL 29

Accepted Solution

by:
bloodredsun earned 500 total points
ID: 13980497
So it's a Struts app?

It's possible that you could using the javascript:
var selectBox = document.getElementById("list") ;

This should get the select box but as it's not within a form i have no idea how it will behave. It certainly not well formed HTML so it might work, or it might not.

It's odd to see the <form> tag used if this is a struts app as in struts you normally use the <html:form> tag.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the below post we have mentioned the best hosting type for startups. Also, check out some of the superlative web hosting companies that are proposing affordable web hosting solutions to host your startup website.
MSSQL DB-maintenance also needs implementation of multiple activities. However, unprecedented errors can hamper the database management. In that case, deploying Stellar SQL Database Toolkit ensures fast and accurate database and backup repair as wel…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month16 days, 20 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question