Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
135
rated 0 times [  140] [ 5]  / answers: 1 / hits: 10374  / 11 Years ago, sun, february 2, 2014, 12:00:00

Please before posting or commenting ... read and understand that this is inside an application that generates the web page and I cannot create a function I can only edit with will happen inside the onclick



Is it possible to use a if function inside an onclick.



The reason why I have to do this is because this onclick is used inside an application that I do not control the code, the only thing I can control is what happens inside the onclick



For example:



onclick=document.getElementById('REF_DOC_1_NUMBER').value = '';


I can write the:



document.getElementById('REF_DOC_1_NUMBER').value = '';


I cannot declare any function in the webpage... cause it's an application that compiles the pages... I can only write what is written in the tag onclick...



But not a function. The page is generated by the application itself so I do not control the header.



What I need, a IF that checks an other ID and to change the value ONLY if the value of the other ID (REF_DOC_1_CHOICE) is NA (not applicable)



Any thoughts?


More From » jquery

 Answers
14

though it is not a good practice to use inline javascript but you can use an if in onclick



onclick=document.getElementById('REF_DOC_1_NUMBER').value = '';if(condition){dosomething}else{dosomething else}

[#48144] Friday, January 31, 2014, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
bobbyallanh

Total Points: 693
Total Questions: 120
Total Answers: 101

Location: Bermuda
Member since Thu, Apr 20, 2023
1 Year ago
;