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 9102481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T01:23:44+00:00 2026-06-17T01:23:44+00:00

So far I’ve not been able to hit on the right way to do

  • 0

So far I’ve not been able to hit on the right way to do it. I’ve got an inputText bound to a variable in an object. I’ve got a selectOneMenu item dropdown all full of goodness. The thought was that when selected, I’d just push the selected text from the dropdown into the input box (simulating typing it). Apparently that’s a no go. I can grab the text of the selected element in a javascript onselect handler easily enough, but the inputText refuses to accept it (presumably choosing to redisplay the stored empty string rather than accept this as input and push it to the object). I’ve also tried setting the string directly in Java, but with the exact same results (of nothing happening). Apparently my entire approach is flawed. What’s the right way to do this? Some sample xhtml code that doesn’t work follows (the java involved is simple getter/setter):

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">
      <script type="text/javascript">
        function dropdownSelect() {            
            var element=document.getElementById("form:dropdown");
            var text=element.options[element.selectedIndex].value;
            document.getElementById("form:part").textContent=text; // TODO doesn't work.  Neither does forcing the part number to change inside the object via Java code
        }
    </script>    
    <h:body>
        <h:form id="form">
            <h:inputText id="part" value="#{part.partNumber}"/>
            <h:selectOneMenu id="dropdown" onselect="dropdownSelect()">                
                <f:selectItems value="#{part.list}"/>
            </h:selectOneMenu>
        </h:form>
    </h:body>    
</html>
  • 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-06-17T01:23:45+00:00Added an answer on June 17, 2026 at 1:23 am

    There are two mistakes:

    1. The select event is the wrong event to hook on change of the HTML <select> element. You need change instead.

      <h:selectOneMenu id="dropdown" onchange="dropdownSelect()">
      
    2. The textContent property doesn’t exist on HTML DOM object representation of the HTML <input> element, the HtmlInputElement. You need value instead.

      document.getElementById("form:part").value = text;
      

    Neither of those problems are related to JSF. It’s just basic HTML/JS. You’d have exactly the same problem on the same HTML content generated by PHP, ASP or even plain HTML.

    For the case you’re interested, the “JSF-ish” way would be something like follows:

    <h:form>
        <h:inputText id="part" value="#{part.partNumber}"/>
        <h:selectOneMenu value="#{part.selectedNumber}">
            <f:selectItems value="#{part.list}"/>
            <f:ajax listener="#{part.changeNumber}" render="part" />
        </h:selectOneMenu>
    </h:form>
    

    with

    public void changeNumber(AjaxBehaviorEvent event) {
        partNumber = selectedNumber;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So far I have not been able to find an answer, but I wanted
So far I am able to make an object called satelite rotate around another
So far I have done this, I am not sure whether this is right
So far I have been able to compile my Java programs in Linux using
As far as I've been able to find out, Windows doesn't offer an API
As far as I've been led to understand, x++ is essentially a terser way
So far I've been setting up redirects for single pages on my ASP.NET site
So far I have only been updated a view from within its controller. I
As far as I can see this is not the case, however, I thought
As far as I know there is no way to migrate existing Facebook comments

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.