29 users online (1 members and 28 guests)  


Page 1 of 2 1 2 Last
  Results 1 to 15 of 18

Related

  1. Replies: 3
  2. Replies: 3
  3. Background-color problem    Forum: CSS Forum
    Replies: 1
  4. Changing Color of Text Box Scroll Bar    Forum: HTML Forum
    Replies: 4
  5. Changing Text Box Scroll Bar Color    Forum: HTML Forum
    Replies: 1
  1. #1
    arvindikchari's Avatar
    New User

    Status
    Offline
    Join Date
    Dec 2008
    Posts
    23

    Post changing background color of a section using css and javascript

    Hello,

    I have a preview section, where a user can dynamically specify a background color for that section

    Part 1. CSS Code for the body portion named as mysbody

    mysbody {
    margin: 5px;
    background-color: #ffffff;
    background-attachment: scroll;
    background-repeat: repeat-x;
    background-position: top;
    }

    Part 2. Javascript function used to change the backgrounf color for mysbody

    var ms_body = getObjectStyle("mysbody");

    ms_body.backgroundColor = value;

    'value' is passed to the javascript function as a parameter in the function call

    This is the code used to update the background color, but for some reason it is not working, can you figure out why it is not working

  2. #2
    rangana's Avatar
    Moderator/Allstar

    Status
    Offline
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    317

    Re: changing background color of a section using css and javascript

    Have you tried on adding highlighted:
    Code:
    ms_body.style.backgroundColor = value;
    If nothing works, please let us know what getObjectStyle() function does.
    Checkout my porfolio.
    Please click the button when a member helped you.
    Take time to use Forum's Search function.

  3. #3
    arvindikchari's Avatar
    New User

    Status
    Offline
    Join Date
    Dec 2008
    Posts
    23

    Post Re: changing background color of a section using css and javascript

    Hello Rangana,

    The following is code for getobjectsyle:

    function getObjectStyle(objectId) { var obj = getObject(objectId); return obj.style;}

    Currently the JS functions for changing the background color are invoked, can you provide code so that directly in the PHP File, I can specify the background color to change without using js?

    Regards
    Arvind

  4. #4
    rangana's Avatar
    Moderator/Allstar

    Status
    Offline
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    317

    Re: changing background color of a section using css and javascript

    How is that function being called?

    Also, you need to show to us the getobject() func too.

    Could you please provide a link to your page instead?
    Checkout my porfolio.
    Please click the button when a member helped you.
    Take time to use Forum's Search function.

  5. #5
    arvindikchari's Avatar
    New User

    Status
    Offline
    Join Date
    Dec 2008
    Posts
    23

    Re: changing background color of a section using css and javascript

    Hello,

    The site is at http_//gb.designshack.info/

    Regarding the code:

    <Part 1: CSS CODE>

    mysbody {
    margin: 5px;
    background-color: #ffffff;
    background-attachment: scroll;
    background-repeat: repeat-x;
    background-position: top;
    }


    <PART 2: Code within PHP File to change the color>

    <div class="kpeoption"> <strong>Background Color:</strong><br />

    <br />
    <input type="checkbox" id="s_sbgc-trans" name="s_sbgc-trans" onClick="kpe_transparent_mainbg()" value="transparent" />
    Fully Transparent <span class="note">(Optional)</span><br />
    <div id="s_sbgc-wrapper" style="display:block">
    <iframe name="s_sbgc-picker" id="s_sbgc-picker" src="js/rgbd4d5.html?rgb=255,255,255" frameborder="0"></iframe>
    <br />
    </div>


    <PART 3: Code Within the Application.js which uses rgbd4d5.html>

    function kpe_update(property, value)
    {
    if (page_loaded) {

    var ms_body = getObjectStyle("mysbody");
    switch(property)
    {
    // Body Background
    case 'backgroundColor': ms_body.backgroundColor = value; break;
    ...
    ...
    ...
    ...
    ...

    }





    I AM NOT SURE ABOUT ONE THING, I cant see any call to
    kpe_update("BackgroundColor", <value>) within the code.
    Please tell me what should be the code to invoke kpe_update and I will check if it is in the code or not, maybe thats why the color is not changing, I am very new to JS and CSS.

    Also ,I would like to attach the code but I am getting an error when I try doing it.

    Regards
    Arvind

  6. #6
    arvindikchari's Avatar
    New User

    Status
    Offline
    Join Date
    Dec 2008
    Posts
    23

    Re: changing background color of a section using css and javascript

    Hello,

    The code can be downloaded from designshack.info/template_creator.zip

    Regards
    Arvind

  7. #7
    jthayne's Avatar

    Status
    Offline
    Join Date
    Aug 2008
    Location
    Texas
    Posts
    508

    Re: changing background color of a section using css and javascript

    What it looks to me the issue is that you have the background color for pageSurround set to a color. Change it to transparent, and see if that helps.

  8. #8
    arvindikchari's Avatar
    New User

    Status
    Offline
    Join Date
    Dec 2008
    Posts
    23

    Re: changing background color of a section using css and javascript

    Hello Rangana/jthayne,

    It is not working with pagesurround's background set to transparent.


    Also, I am willing to pay either of you $30 via Rentacoder, if you can make the whole template creator work

    Regards
    Arvind

  9. #9
    jthayne's Avatar

    Status
    Offline
    Join Date
    Aug 2008
    Location
    Texas
    Posts
    508

    Re: changing background color of a section using css and javascript

    I will be glad to help you. However, my job will not allow me to take any money for it. (And you don't want to pay their rates). Send me more details in a PM, and I will get it going.

  10. #10
    arvindikchari's Avatar
    New User

    Status
    Offline
    Join Date
    Dec 2008
    Posts
    23

    Post Re: changing background color of a section using css and javascript

    For changing the background color of the section named 'colLeft'. following is the code :


    var cl=parent.getElementById('colLeft');

    cl.style.backgroundColor = "rgb(" + r.getValue() + "," + g.getValue() + "," + b.getValue() + ")";


    Regards
    Arvind

  11. #11
    arvindikchari's Avatar
    New User

    Status
    Offline
    Join Date
    Dec 2008
    Posts
    23

    Post Re: changing background color of a section using css and javascript

    Hello,

    Now there is one more problem,

    within pagesurround are various div's which each have their own background image or color, hence when i try to apply the background image or color for pagesurround, it is not applied to those div's which have their own background color or image, how can i overcome this problem

    Regards
    Arvind

  12. #12
    jthayne's Avatar

    Status
    Offline
    Join Date
    Aug 2008
    Location
    Texas
    Posts
    508

    Re: changing background color of a section using css and javascript

    You will need to change the background on each item individually. For example, you already have the following code:
    Code:
    var cl=parent.getElementById('colLeft');
    
    cl.style.backgroundColor = "rgb(" + r.getValue() + "," + g.getValue() + "," + b.getValue() + ")";
    Repeat the lines as follows for every div that will need to be changed (I am adding in the code for an element called 'colRight':
    Code:
    var cl=parent.getElementById('colLeft');
    var cr=parent.getElementById('colRight');
    
    cl.style.backgroundColor = "rgb(" + r.getValue() + "," + g.getValue() + "," + b.getValue() + ")";
    cr.style.backgroundColor = "rgb(" + r.getValue() + "," + g.getValue() + "," + b.getValue() + ")";

  13. #13
    arvindikchari's Avatar
    New User

    Status
    Offline
    Join Date
    Dec 2008
    Posts
    23

    Post Re: changing background color of a section using css and javascript

    Hello jthayne,

    I need that the background plus all other divs work, is there no other way to do this?

    Regards
    Arvind

  14. #14
    jthayne's Avatar

    Status
    Offline
    Join Date
    Aug 2008
    Location
    Texas
    Posts
    508

    Re: changing background color of a section using css and javascript

    I am looking through the code on the link you provided earlier, and am not seeing where you are talking about.

    Do you want to change the value of only one div or of more than one div at a time (to the same color)?

  15. #15
    arvindikchari's Avatar
    New User

    Status
    Offline
    Join Date
    Dec 2008
    Posts
    23

    Post Re: changing background color of a section using css and javascript

    Hello,


    ON this page, there are some DIVs which are supposed to show the background color / image of pagesurround. But there are other divs which have their own bg color/image. WHen I tried to code this, I found that the pagesurround bg was shown only till the point where a div appeared which had its own bg, after that THE BG OF PAGESURROUND WAS NOT SHOWN AT ALL (after this div, only the backgrounds of various individual divs were shown, even if a div did not have individual bg, it was showing white background, NOT THE BG OF PAGESURROUND)

    I want that all divs which do not have individual bg, should display the bg of pagesurround, is it possible to do that
    NOTE The bg of pagesurround may be a color or image also

    Regards
    Arvind



Page 1 of 2 1 2 Last

Tags for this Thread