Using javascript to change styles and such

I want ot use javascript to change the "display" style of a
div tag
whatDiv.style.display = "block"
This works fine if the div tag has an inline style defined:
<div style="display:none"> ...</div>
But if the tag has a class attached to it and the display
:none is attached
to that class, then it doesn't work
<style...>
div.hidden{ display:none; }
</style>
<div class="hidden"> ... </div>
... how can I remedy this?

On Thu, 15 Jun 2006 17:20:54 +0000 (UTC), "jeremyluby"
<[email protected]> wrote:
>What gary is saying is that you should not use a class,
but an ID only to
>define the region.
Nope. That's not what I'm saying. Regardless of whether
you're using a
class or not, if you get an object reference using an ID, you
can change
the properties. Consider this example:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<title>Demo</title>
<style type="text/css">
.demo {
background-color: #000099;
border: 1px solid #000;
color: #ffffff;
text-align: center;
height: 60px;
width: 500px;
</style>
<script type="text/javascript">
var bg="#009";
function changeColor(x){
o=document.getElementById(x);
bg=(bg=="#009"?"#900":"#009");
o.style.backgroundColor=bg;
</script>
</head>
<body>
<div id="test" class="demo">
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing
elit.</p>
</div>
<p><a href="javascript:;"
onClick="changeColor('test')">Change
Color</a></p>
</body>
</html>
Gary

Similar Messages

  • Using javascript to change the "Overall Result" cell in WAD

    Hi experts,
    I am trying to use javascript to change the text of the "Overall Result" cell in my web template using BI 7.0. I am not familiar with javascript, but I this is what I have done so far.
    I dragged the web item "Script" into my web template and I inserted the following code:
    function change_overall_result_to_average() {
    var cell = document.getElementsByTagName("TD");
    var cellText;
    for (i = 0; i < cell.length; i++)
          cellText = cell<i>.innerText;
               if (cellText == "Overall Result")
                     cell<i>.innerText = "Average";               
    In the XHTML view I am using added the onload function to start the javascript every time the web template is loaded. The code works fine when the web template is first loaded and the cell text is changed to "Average". However, if I navigate in my web template, the javascript function is not triggered, and the cell is therefore changed back to "Overall Result". For example, this happens when I pick another selection from one of my dropdown boxes, such as changing the selection from year 2008 to year 2007.
    I don't really know how to solve this problem in an easy way, and the current solution is not good enough. I hope one of you guys can suggest an easy way of fixing this:-)
    Best Regards,
    Morten

    Woodstock apparently renders some Javascript/DOM with some homegrown widget framework which on its turn renders the HTML DOM tree instead of plain vanilla HTML. Correct me if I'm wrong, to confirm this, just view the generated HTML source of the page.
    After some Googling I found out that you need getProps() and setProps() to get and set element attributes respectively.
    [http://google.com/search?q=webuijsf+domnode+site:sun.com].
    If you stucks with this, I recommend you to post this question at a forum or mailinglist devoted to Woodstock, e.g at their own homepage at dev.java.net or the Netbeans forum at nabble.com. You're here at a Sun JSF forum, not at a Woodstock forum.

  • How find the missing glyph using javascript [like indesign preflight], and replace same glyph available font or

    The situation:
    I want to use basetext font, but some of the glyphs are missing in it, and are highlighted with pink boxes. common font [stix, etc.] have much more glyphs than basetext font. I can apply common font [stix, etc.]manually for each of the missing glyphs or insert two character and use kerning set it up, but it is tedious.
    Question:
    How find the missing glyph using javascript [like indesign preflight], and replace same glyph available font or insert two character and use kerning set it up?
    Any one know how to do this?
    Thanks in Advance,
    ~Jack

    Try Peter kehrl's script
    http://www.kahrel.plus.com/indesign/missing_glyphs.jsx

  • Using javaScript to change a field from required to not required

    Hi,
    I have what seems like a simple question .I would like to know if it is possible to have a function call from my jsf code to a javascript function which could change a text field input from required to not required .
    I can do this through the server but would prefer to do it in the front end .
    e.g . I have a pull down list and when I click on one of the values it calls a function in javascript which changes a text field from required to not required .
    Hope this is clear .
    Thanks for your help.

    Instead of having the field required on the component defeiniton, put that requirement on code.
    Either way you can't do that on javascript. If you could do that then you could fool the aplication...

  • Using Javascript to change multiple text field names

    I have a pdf with multiple text fields. I need to change all the text field names (General -> Name) so that they are unique so that when I combine multiple pdfs together, the text fields will stay intact. Is there anyway to do this using javascript? Thanks!

    I'm new to javascript too...it will be very helpfull for me too...Thanks
    poltrone
    prodotti chimici

  • Change Styles and Skins

    Hi,
    Can Styles and/or Skins be changed by login id?
    Thanks?

    Skins can be varied at the time of user login. They can be dynamic(You can set the SKIN system variable dynamically in the repository). But styles do not have that option since styles can vary from one dashboard page to another and hence are not specific to a user.
    Thanks,
    Venkat
    http://oraclebizint.wordpress.com

  • It possible using javascript to change the value of another jsf text field?

    In my case, I have an input text field and would like to copy it's value on the onchange() event into another text field. Using the destination text field's Id and assigning some content with it's .value property

    Woodstock apparently renders some Javascript/DOM with some homegrown widget framework which on its turn renders the HTML DOM tree instead of plain vanilla HTML. Correct me if I'm wrong, to confirm this, just view the generated HTML source of the page.
    After some Googling I found out that you need getProps() and setProps() to get and set element attributes respectively.
    [http://google.com/search?q=webuijsf+domnode+site:sun.com].
    If you stucks with this, I recommend you to post this question at a forum or mailinglist devoted to Woodstock, e.g at their own homepage at dev.java.net or the Netbeans forum at nabble.com. You're here at a Sun JSF forum, not at a Woodstock forum.

  • Using JavaScript to change field in a Form

    I have a form with few fields. When a field 1 changes, I want field 2 automatically changes to "TBD". Can I do that with Javascript OnChange?
    Obviously I tried that but it doesn't work. I don't know much about javascript. Any help is appreciated.
    650-604-3035
    [email protected]

    Hi,
    Since in forms the fields are named diffently you cannot directly access the variables by the name. For example the column "EMPNO" in a form "EXAMPLE_FORM" is named as "EXAMPLE_FORM.DEFAULT.EMPNO.01"
    In the onChange event of field 1 the code would be something like this.
    for (i=0;i<document.forms[0].elements.count;i++)
    //gets the value of <field_name_1>. <field_name_1> can be copied from the html source.
    if (document.forms[0].elements.name == "<field_name1">)
    l_value = document.forms[0].elements[i].value;
    //sets the value of <field_name_2>. <field_name_2> can be copied from the html source.
    if (document.forms[0].elements[i].name == "field_name2")
    document.forms[0].elements[i].value = l_value;
    Hope that helps.
    Thanks,
    Sharmila

  • ECH - ECM -- Change leaders and change packages using alternative dates

    Our company is an engineer to order business.  The Engineering Managers would like to be able to see all the work/changes to objects that occurred for a customer project.  So, the use of a change leader and change packages seems to make sense to allow the managers to see all the objects related to a project, but at the same time allow various sub-assemblies be released at different dates. 
    I was planning to set the change leader with the date of the final erection of the piece of equipment and then use the change packages with alternative dates to release the drawings and sub-assemblies as needed to ensure the appropriate delivery time. 
    However, even though I can use alternative dates in the change package, I don't get a pop-up window when assigning the change package to the document or BOM for selecting the appropriate date for the object. 
    Is there a setting I need to enable for this to work? 
    Thanks!
    -J

    I didnt understand what your requirement exactly is....
    but if you are trying to shift all BOM data from 4.6 C to some higher version of SAP , to my knowledge ...
    SAP does not support upward compatibility......

  • Table of contents: Style and numbering

    Hi all,
    I've already found some information about the page numbers in the Toc here on the forum, so thank you for posting that.
    What I can't find is this: I've got my table of contents with the page numbers aligned to the right side. The toc consists all the titles I've used in my Pages document. In this document I gave these titles different numbers, i.e. I've used the styles for creating a list. So in my document I have something like this:
    1 Food
    1 1 Vegetables
    1 1 1 Carrots
    text about carrots
    1 1 2 Tomatoes
    text
    1 2 Fruit
    1 2 1 Apples
    text about apples
    1 2 2 Lemons
    text about lemmons
    2 Drinks
    2 1 Hot drinks
    2 1 2 Coffee
    text..
    I don't want to start a discussion about wheter or not a tomato is a fruit or a veg . I would like to know how i get these numbers in my Toc ? Right now I have this toc :
    Food 1
    Vegetables 1
    Carrots 1
    Tomatoes 2
    Fruit 3
    Apples 3
    Lemons 4
    Drinks 5
    Hot drinks 5
    Coffee 6
    But I want something like this :
    1 Food 1
    1 1 Vegetables 1
    1 1 1 Carrots 1
    1 1 2 Tomatoes 2
    1 2 Fruit 3
    1 2 1 Apples 3
    1 2 2 Lemons 4
    2 Drinks 5
    2 1 Hot drinks 5
    2 1 2 Coffee 6
    Can somebody show me how to do this ? And also, is there a possibility of changing the text layout in this Toc according to the layout I've used for these titles in my Pages document ?

    Actually, yes, it was tedious, but I gave the numbering in the heading styles a fair go. tried my own indented numbering styles. When the doc becomes large enough, the auto-numbering breaks. I write fairly intense technical docs, with legal (or tiered) numbering, I cannot afford either the incorrect numbering, or the ToC not showing the numbered heading.
    Typing the number into the heading, and using say 4 heading styles for four level of detail (tiers), works well. But do not start until the doc is fairly stable, and thus the numbers do not change. These numbers show up in the ToC very nicely. You can use didferent ToC Heading styles and make that look good as well.
    And, yes, I have requested the feature. What I really want is the heading sytle to remember the indent/tier level and keep track of it; and not get lost in a large doc; THEN showing that number in the ToC.
    Cheers
    Derek

  • Certificate Encryption using JavaScript

    All:
    I am encrypting documents using a certificate.  This code works exect that the document restrictions are not employed.
    After the code is executed, all the document restrictions (Document Properties -> Security -> Document Restriction Summary) are "Allowed".  When "Change Settings" is clicked, the Certificate Secuirty Settings window appears.  After clicking "Next", the Permissions group box has all the correct permissions; HOWEVER, when one clicks "Permissions..." the check box "Restrict printing and editing of the document and its security settings" is not ticked.  After ticking the "Restrict printing..." check box and saving the document (notice no other settings were chaged), the permissions are removed.
    How does one use JavaScript to "Restrict printing and editing of the document and its security settings"?
    var curDoc = this;
    var certPath = "/C/Documents and Settings/rrh/Desktop/Sample/";
    var cliCertFile = "CertFile.cer";
    var cliCert = security.importFromFile({cType:"Certificate", cDIPath:certPath + cliCertFile});
    var cliEntity = [{defaultEncryptCert:cliCert}];
    var cliPermissions =
        allowAll: false,
        allowAccessibility: false,
        allowContentExtraction: false,
        allowChanges: "none",
        allowPrinting: "lowQuality"
    curDoc.encryptForRecipients(
        oGroups:
            {userEntities: cliEntity, permissions: cliPermissions}
        bMetaData:true,
    Special Kudos to Patrick who helped with document certification in JS.

    I GOT IT!  The issue was an error of omission: curDoc.saveAs(curDoc.path);
    var curDoc = this;
    var cliPath = "/C/Documents and Settings/rrh/Desktop/Sample/";
    var cliCertFile = "CertFile.cer";
    var cliCert = security.importFromFile({cType:"Certificate", cDIPath:cliPath + cliCertFile});
    var cliEntity = [{defaultEncryptCert:cliCert}];
    var cliPermissions =
        allowAll: false,
        allowSecuritySettings: false,
        allowAccessibility: false,
        allowContentExtraction: false,
        allowChanges: "none",
        allowPrinting: "lowQuality"
    curDoc.encryptForRecipients(
        oGroups:
            {userEntities: cliEntity, permissions: cliPermissions}
        bMetaData: true,
        bUI: false
    curDoc.saveAs(curDoc.path);
    Other changes are the including
    1) allowSecuritySettings: false
    2) bMetaData: true, bUI: false
    It seems the document needed to be saved using JavaScript immediately after adding the security.  When trying to save the documentby File -> Save; the "The document could not be saved. Bad Paramater." error would appear.  By saving the document in code, the encryption is properly applied.  After closing and re-opening the document, all permissions are "Not Allowed" except for printing.
    Edit:
    This code functioned in the console.

  • Set client var using javascript

    i have a form where a user enters a line of info, and i want
    to save that as a client variable without having to post the form.
    is it possible to set a CF client variable using javascript?

    > cookies can be created/edited/deleted using js, so i just
    need
    > to know how i would go about editing a cf created
    cookie using js.
    You've inched away from your original question. It was about
    how to use Javascript to save form data in Coldfusion without
    having to send the form from the browser. The answer is, you can't.
    > i used javascripts document.cookie to make changes to the
    correct coldfusion
    > client variables..works like a charm
    You've not changed any Coldfusion variable at all. What
    you've simply done is use Javascript to write a new cookie, which
    Coldfusion then reads later. To see that, do this test.
    Save and run the following code as the page
    testCookieJS.cfm
    <html>
    <head>
    <title>testCookieJS</title>
    <script type="text/javascript">
    document.cookie="JS test cookie";
    </script>
    </head>
    <body>
    Coldfusion cookie struct dump:
    <cfdump var="#cookie#">
    </body>
    </html>
    You will find that the "JS cookie" is not dumped. However,
    you will find that the cookie is actually present in the browser.
    Now, close the browser and delete all cookies. Save and run
    the following code as the page
    testCookieCF.cfm
    <cfcookie name="CFCookieTest" value="CF test cookie">
    <cfdump var="#cookie#">
    You will find that the "CF cookie" is dumped. The difference
    in the result of the two tests shows that one cannot use Javascript
    to change the cookie that Coldfusion sets. In fact, generally
    speaking, you cannot use Javascript to modify any Coldfusion
    variables. If you could, anyone would be able to use an HTML page
    to rewrite your Coldfusion site.

  • How to add a polygon to mapviewer using Javascript API

    Hi,
    I am using JavaScript API for the MapViewer.
    Using redlining tool, my application allows user to draw polygon onto the map.
    I would like to have union, difference and intersect tools. I know the back end logic can be done using using JTS or SDO_Union, SDO_difference, and SDO_intersection. but how do i display the result polygon on the map? Note that I am not going to store the polygon in the database.
    Thanks for any ideas.

    Hi,
    If I understand well you are using Oracle Maps. User do some redlining, then you somehow makes FOI polygons. Then you get the coordinates of the polygons and send them to the back-end where you can use spatial functions and get the coordinates of the new polygon.
    You can store those coordinates in i.e. hidden input field on page (if you use JSF it is very simple) and then use JavaScript to parse them and Oracle Maps API to create new FOI polygon and add it to mapviewer object. One disadvantage of this concept is that reloading of page (submit) is necessary.
    Branislav

  • How to get a adf text area width using javascript

    hi
    i have to catch different input text width(i.e 30px,500px.etc) dynamically using javascript(adf:clientListner)
    Thanks and regard
    B.Maheswara Reddy

    Hi,
    its af:clientListener, not adf:clientListener.
    af:clientListener passes an event to the JavaScript method
    function getWidthOfComp(event){
    alert(event.getSource().getWidth());
    }

  • How to use JavaScript to supply a value for a MessageTextInput field

    With the text attribute you can supply a deafult value for text field. Is it possible to supply this field with a default value determined by javascript ?
    <messageTextInput name="startDate" text="..." ...

    Marcel,
    If you want to dynamically set a value for a text field, there are two approaches you can use:
    1. use javascript (the browser language) and then for your <body> element's onload handler, invoke a javascript method that sets your form value.
    2. use java (the compiled language) and databind the "text" attribute of messageTextInput to a dataobject that gives the current date. If all you're looking to do is bind to the current date, I'd recommend this approach.
    Hope this helps,
    Ryan

Maybe you are looking for