0

I have a js file(abc.js) and having a function increment().Which stores count of places as var noOfPlaces.

In the xhtml file.Have a component which is having onclick function.

I want to have if else condition inside onclick based on noOfPlaces.

abc.js

function increment(){
var noOfPlaces=(some methods);

cde.xhtml

 <a4j:commandLink id="Import" type="submit"
 rendered="#{()}"
onclick="focusOn('Import');if else condition

How can we use jaavascrpt variable value in xhtml page and write if else condition in onlick> I know how to use javamethods in xhtml (classname.methodname).How can we do for js file Thanks in advance

4
  • Javascript runs client side in the generated html, not server side in the xhtml. Commented Jul 7, 2020 at 12:10
  • @Kukeltje So we cannot use that variable inside xhtml page? Sorry..I am new to this Commented Jul 7, 2020 at 12:29
  • See stackoverflow.com/questions/28591301/… Commented Jul 7, 2020 at 12:58
  • 3
    Your question is very ambiguous. Your problem seems to actually have nothing to do with JSF. Please take a step back and create a test page using plain vanilla HTML, e.g. <a href="#" onclick="..."> instead of <a4j:commandLink onclick="..">. If you still face exactly the same JavaScript problem there in the plain vanilla HTML page, then it's definitely not JSF related and you need to rewrite your question. Note that even when it's actually JSF related, your problem would still have got nothing to do with "XHTML". Commented Jul 7, 2020 at 13:17

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.