aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes One Form with Many Links (Each has Its Specifics) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "One Form with Many Links (Each has Its Specifics)" Watch "One Form with Many Links (Each has Its Specifics)" New topic
Author

One Form with Many Links (Each has Its Specifics)

Natalie Kopple
Ranch Hand

Joined: May 06, 2003
Posts: 325
I must use the Javascipt to do what I am trying to do. Therefore, please do not try to persuade me to do it other than using the Javascript.

I have one form with many links in it. Each link has its own specifics to be submitted. Let me try to make it simple and explain:

The first link is associated with sortKey="firstName" and orderKey="ASC"
The second link is associated with sortKey="firstName" and orderKey="DESC"
The third link is associated with sortKey="lastName" and orderKey="ASC"
The fourth link is associated with sortKey="lastName" and orderKey="DESC"

Therefore, all the text fields, text area, menu selections in that form together with the link specifics are submitted when each link is clicked.

It seems to me that I have to define a function and some sort of a HashMap and then wirte javascript"document.forms[0].submit();

Please advise the exact way to do it. I am really not good at the Javascript and need help. Thank you very much in advance.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

You could have 2 hidden fields. 1 for the sortKey and 1 for the orderKey. When you click a link, change the values of the hidden fields depending on which link you clicked and then to document.myForm.submit();


GenRocket - Experts at Building Test Data
Natalie Kopple
Ranch Hand

Joined: May 06, 2003
Posts: 325
I still do not have a clear idea about how it is done.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61206
    
  66

Do you know what a hidden field is?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Natalie Kopple
Ranch Hand

Joined: May 06, 2003
Posts: 325
Yes. The hidden field is similar to a text field but not visible to users.

But, how do I alternate the value of those two fields depending on the link clicked by users?

The links are coded like:

[ July 20, 2006: Message edited by: Natalie Kopple ]
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Do you have to use actual anchor links? I might do something like this:



The spaces in script and onclick are there so that this could be posted.
[ July 20, 2006: Message edited by: Gregg Bolinger ]
Natalie Kopple
Ranch Hand

Joined: May 06, 2003
Posts: 325
Yes, I have to use actual anchor links.

I have rarely used the Javascript. Therefore, I am very easy to get disoriented.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Originally posted by Natalie Kopple:
Yes, I have to use actual anchor links.

I have rarely used the Javascript. Therefore, I am very easy to get disoriented.


Ok, so exact same procedure as I described, but use <a> (anchor tags) instead of the DIV and give it an HREF="#" instead of the submit();
Natalie Kopple
Ranch Hand

Joined: May 06, 2003
Posts: 325
I got the idea. Thanks a lot, Bear.

It is one of the many details that I have to handle to deliver the application at work.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: One Form with Many Links (Each has Its Specifics)