• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

One Form with Many Links (Each has Its Specifics)

 
Ranch Hand
Posts: 325
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I still do not have a clear idea about how it is done.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic