• 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

html:link tag with javascript handler

 
Ranch Hand
Posts: 472
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
good day to all,

i using <hmtl:link> to forward to another page as follow


however, i would like to check all other form fields and make sure no blank data is in these fields , so when onClick, "doForward()" will check the completeness, if some fields is not filled in , then the action "measure_predetail2" will not execute

here are the javascript function, if doCheckcomplete return true, it will execute the action else it doesn't


but it seem doesn't work well here , when the fields is filled then it will forward to next page, when not fill in the fields, it will call the form action instead, what i need is if no fill in, then the page do nothing and remain static with some error msg,

how to let the page not call any action(specially for form action) when client validation is fail ?

note : measure_predetail2.do will forward current page to next page

thank you for enlighten
[ November 12, 2006: Message edited by: Nakata kokuyo ]
 
Ranch Hand
Posts: 228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have some return value (boolean value for the function

You have some function called in onclick
inside the function to return false if validation problems
else return true

If validation fails, the page remains there itself else
it will trigger the action
 
Nakata kokuyo
Ranch Hand
Posts: 472
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i do exactly what you suggest in previous , here is my further code



1. when the fields is filled then it will forward to next page >> correct
2. when field is blank, it will call the form action instead but page not remain >> not correct
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Since your JavaScript function handles the submit, you really don't want the link to do anythng at all. I'd suggest the following:

<a href="javascript:void(0)" onnclick="doForward()">click here</a>

The <html:link> tag doesn't really add any value here, so I just used the regular html <a> tag.
[ November 12, 2006: Message edited by: Merrill Higginson ]
 
Nakata kokuyo
Ranch Hand
Posts: 472
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Merrill Higginson , if i change it to <a> tag with javascript:void(0) , when i click on link, it will remain but also notice that even the onnclick() is active but seem not forward to other page anymore
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are there any JavaScript errors? Can you put alert statments in your JavaScript code to verify that the code makes it as far as the submit statement?
 
Nakata kokuyo
Ranch Hand
Posts: 472
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
there have no error , i have put alert() right after document.forms[0].submit() , it does alert me but no submit() invoke, however , if i try it using button , it work fine

how come link or image not working in this case ?
[ November 13, 2006: Message edited by: Nakata kokuyo ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic