Current position:  Home > Default > Visual JSf: textField hide or disable, when selecting dropDown list

Visual JSf: textField hide or disable, when selecting dropDown list

Time:November 30
Advertisement
Hello everyone,
I am new to this forum, I am working on Visaul JSF, I have a question,
When i select a value dropDown List, i want to disable or hide textField depending on the selected item in the list.
I have put javascript for dropDown list. I am not able to do this. Can any one help me please...
<webuijsf:script>
                    function fun(sel){
                        var state = sel.options[sel.selectedIndex].value;
                        alert(state);
                        if(state == 2){ alert("if");  document.getElementById('form1:textField2').disabled='true' }else{ alert("else"); document.getElementById('form1:textField2').disabled='false'}
                </webuijsf:script>for downdown, i have added this..
onChange="fun(this)"In dropdon list
name value
One 1
Two 2
Three 3
Jsp code:
<jsp:root version="2.1" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:webuijsf="http://www.sun.com/webui/webuijsf">
    <jsp:directive.page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"/>
    <f:view>
        <webuijsf:page id="page1">
            <webuijsf:html id="html1">
                <webuijsf:script/>
                <webuijsf:script>
                    function fun(sel){
                        var state = sel.options[sel.selectedIndex].value * 1;
                        alert(state);
                        if(state == 2){ alert("if");  document.getElementById('form1:textField2').disabled='true' }else{ alert("else"); document.getElementById('form1:textField2').disabled='false'}
                </webuijsf:script>
                <webuijsf:head id="head1">
                    <webuijsf:link id="link1" url="/resources/stylesheet.css"/>
                </webuijsf:head>
                <webuijsf:body id="body1" style="-rave-layout: grid">
                    <webuijsf:form id="form1">
                        <webuijsf:textField id="textField2" onChange="" style="height: 18px; left: 174px; top: 258px; position: absolute; width: 216px"/>
                        <webuijsf:button id="button1" onClick="return fun()" style="position: absolute; left: 228px; top: 324px" text="Button"/>
                        <webuijsf:dropDown id="dropDown1" items="#{Page3.dropDown1DefaultOptions.options}" style="position: absolute; left: 312px; top: 90px" onChange="fun(this)"/>
                    </webuijsf:form>
                </webuijsf:body>
            </webuijsf:html>
        </webuijsf:page>
    </f:view>
</jsp:root>Thanks in advance
Neha
Edited by: Neha_540 on Apr 5, 2009 11:02 PM
Edited by: Neha_540 on Apr 5, 2009 11:05 PM
Advertisement
Hi Neha,
Hope this helps.
function changeMarital()
                            var marital = document.getElementById('form1:drpMarital_list').value;
                            if(marital == "Others")
                                document.getElementById('form1:lblOtherMarital').style.display='';
                                document.getElementById('form1:txtOtherMarital').style.display='';
                            else
                                document.getElementById('form1:lblOtherMarital').style.display='none';
                                document.getElementById('form1:txtOtherMarital').style.display='none';
                        }

Set text in Visual JSF textfield from javascript

-0001-11-30

HI, I want to pass a variable from a javascript to put into a visual jsf textfield that is connected to a Bean variable like this: <webuijsf:textField id="myLat" style="left: 96px; top: 336px; position: absolute" text="#{Create

OBIEE - How to selectively hide or disable columns on a dashboard prompt?

-0001-11-30

Hello! I need some help with OBIEE dashboard Prompts. Any help will be highly appreciated! Question 1. How to selectively hide or disable columns on a dashboard prompt or the entire prompt? There seems to be no "hide" or "dsable" optio

How to disable the selection of "Title and logo URL of a SharePoint 2013 site" from browser

2015-10-11

how to disable the selection of "Title and logo URL of a SharePoint 2013 site" from browser or How can we able to set our custom default log to the sp2013 site using code.So that users are not allowed to change from browser again. Thanks & R

Webdynpro ABAP ALV in SAP ECC6 - EHP4: To disable Column Selection

2015-10-11

Hi All, We are using SAP ECC6 EHP4 and  for Webdynpro ABAP application, after each column a vertical white line is appearing, and I need to hide this.. SAP suggested us to disable COLUMN SELECTION I have tried the below code but still I am not able t

How to hide a block in Selection screen ?

2015-10-11

Hello abap gurus, I have a requirement where I have to hide a block on Selection screen. Can anyone of u give the command for that or code.. Its urgent ! Om Sai Ram, aRgDHi, Just paste the following code in abap editor. *Selectionscreen elements.....

How to use javascript in visual jsf

2015-10-11

I have a web project and I am using visual jsf in netbeans. My problem is I cannot with javasciprt. When I clicked to a button I want to make some check with javascipt and then run server side java code. With jsp I used to add onclick javascipt and i

How can I Hide(not Disable) the Save As and Exit options in the File menu of Excel Documents in SharePoint 2013?

2015-10-11

Hi, I want to hide(not disable) the "Save As" and "Exit" options in the File Menu of Excel Documents in SharePoint 2013.When I make changes in the excelribbon.css file of xlviewer.aspx,all the options under File menu are getting hidden

Is there a way to hide or disable settings in Apple configurator

2015-10-11

Is there a way to hide or disable settings in Apple configurator because the students are resetting them.Sorry but no, there is at present no way to hide or disable the Settings app, nor any of the settings within that app not included in the Restric

Importing visual jsf page into another jsp page

2015-10-11

Hi I am developing a web application using jsp and struts. I want to embed a visual jsf page that Ive created into another jsp page (which is a normal jsp page, not a jsf one.) Ive tried quite a few things but nothing seems to work.. <jsp:include pag

How to disable the Selection screens of LDB's ?

-0001-11-30

Hi,          How to disable the Selection screens of LDB's when we r using the predefined LDB for our executable pgm ? and how to include the predefined LDB  can u write the Code for including LDb or if possible give an example of a Pgm using a Prede

How to disable Multi-selection thing in slicer.

-0001-11-30

Hello, I am using Slicer in Excel Sheet and i want to disable Multi-selection thing in slicer. Is it possible to throw an exception or doesn't allow to do a multiple selection in excel slicer using VBA or without? Quick help ll be appreciated  :) Tha

How to hide input fields on selection screen using variant attribute

-0001-11-30

Hello all, I want to know how to hide input fields on selection screen using variant attribute conpletely. As you know, when setting the attribute of variant "Hide field" checked, the field is temporarily hidden, but when clicking "All Sele

Tree control: How to disable the selection of a child item

-0001-11-30

Hello everyone, Im having trouble with disabling the selection of a child item in a tree control. I dont know if its possible but havent found any answers on this forum regarding this issue. Example: Parent tag 1     child item 1     child item 2 Par

How to disable the select options button, while audio is playing in the question template in captivate 8?

-0001-11-30

How to disable the select options button, while audio is playing in the question template in captivate 8?Apologies for late reply. I mean "On Question screens audio keeps on playing even after we have selected an option or options depending on the qu

How do I disable auto select for the path selection tool?

-0001-11-30

For the move tool you can choose to disable auto selection, auto select a group, or auto select a layer. By default though the path selection tool autoselects a layer. How can I disable autoselection?I can't seem to reproduce what you describe. Pleas

Getting problem in binding DropDown List with table data in visual JSF

-0001-11-30

Hi All, I am new to visual JSF. I am getting few problems while working over components. I have succeeded in binding data of Person table in a drop down list . By just drag drop ..it worked. But while connecting to external DB this drag drop mechanis

Hide or Disable shutdown

-0001-11-30

Hello Experts! Is there a way to hide or disable the shutdown button on windows 7 using GP. The domain controller is server 2008R2. I saw the option to disable shutdown, restart, hibernate... but I want to leave users the option to restart. Thanks in

Visual JSF pages

-0001-11-30

am having a problem with a web app i am making using visual JSF pages. I am interacting with a MYSQL database. I have a problem with displaying the blob types from the database in the actual visual table and on screen,. I have tried converting it to

How to hide F8 function on selection screen.

-0001-11-30

Hi, How to hide F8 function on selection screen.Just create a customer status and SET this status in your INITIALIZATION block. <i>You can copy the standard status from program RSSYSTDB status %_00.</i> RegardsRead other 5 answers