Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7516619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:11:21+00:00 2026-05-30T01:11:21+00:00

I am trying to access the value of jsf outputText value using javascript but

  • 0

I am trying to access the value of jsf outputText value using javascript but it throws undefined.Below is the code

    <ui:composition template="/template.xhtml">
            <ui:define name="head">
                <script type="text/javascript">
                    function sendDetails()
                    {
                        alert("am inside js");
                        var key=document.getElementById('editForm:key').value;
                        alert(key);
                    }
                </script>
            </ui:define>
    <ui:define name="body">
                <f:view>
                    <h:form id="editForm">
                        <h:outputLabel id="key" value="#{editController.details.clientId}" style="font-weight: bold" >
 <h:commandLink id="analytics" onclick="sendDetails()" value="View"></h:commandLink>

     </h:form>
     </f:view>
     </ui:define>
     </ui:composition>

When I click the command link it throws undefined!! I am not able to access the value of the output label.I checked view page source in firebug

<label id="editForm:key" style="font-weight: bold">

1e20bb95-753e-4252-b6d6-e109fa07171e

Which seems right..I checked with console.log(document.getElementById('editForm:key')) console.log(document.getElementById('editForm:key').value)which showed <label id="editForm:key"> undefined

How do I access the label/jsf outputtext value.I need a solution in javascript only

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T01:11:23+00:00Added an answer on May 30, 2026 at 1:11 am

    You can’t get h:outputLabel value with .value, because its being rendered into HTML label tag and you can’t get h:outputText value with .value, because its being rendered into HTML span tag.

    Use .innerHTML instead for both tags.

    You can find all its attributes with Firebug. Add this to watch

    document.getElementById('editForm:key')
    

    for example, here are more attributes that hold its text

    .innerHTML
    .outerText
    .textContent
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to access textbox value using the jQuery code; $(#pg_textbox).val(); But it
I'm trying to access a cookie's value (using $_COOKIE ) immediately after calling the
I'm trying to access the number in the below element, but I'm having trouble
I am trying to access the i18n properties file I'm using in my JSF
I have this example where I am trying to access json value, but it
I'm trying to access a value from the code behind to create a query
I am trying to access the integer value of the first cell but I'm
I am trying to access the Event Code value (which is a unit) like
I'm trying to access an associative array's key and value from within the same
When I access a JPA managed date value from JSF, it comes back with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.