Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

One Form with Many Links (Each has Its Specifics)

 
Natalie Kopple
Ranch Hand
Posts: 325
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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();
 
Natalie Kopple
Ranch Hand
Posts: 325
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I still do not have a clear idea about how it is done.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64838
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you know what a hidden field is?
 
Natalie Kopple
Ranch Hand
Posts: 325
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 325
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 325
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic