Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jan 2007
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Using onclick to change data in an object

    I was given the following code in hopes that it would replace the 'data' attribute in an object. I've toyed with it and can't seem to get it to work. I was wondering if anyone here knew how to fix it. The link to the page is http://activities.fit.edu/aiaa/Test/...ate/roster.htm

    PHP Code:
    <script type="text/javascript">
    function 
    changeData(filePath)
    {
    document.getElementById("window").data "filePath"
    }
    </script>  
        <div id="profiles">
            <dl>
                <dt>Officers</dt>
                    <dd onclick="changeData('roster/theman.htm')">President: The man</dd>
                    <dd>Vice President: the other man</dd>
                    <dd>Treasurer: other other man</dd>
                    <dd>Captain: the other</dd>
                    <dd>Coach: the other other</dd>
                <dt>Average Beings</dt>
                    <dd>Peasant1</dd>
                    <dd>peasant2</dd>
                    <dd>peasant3</dd>
                    <dd>peasant4</dd>
            </dl>
            <object name="window" type="text/html" data="roster/Rosterblank.htm">
                Error!
            </object> 

  • #2
    Senior Coder
    Join Date
    Nov 2006
    Posts
    1,000
    Thanks
    0
    Thanked 0 Times in 0 Posts
    One place to start is to change the <object> tag and add id="window" since you are using the getElementById() function.

    Another is to get rid of the quotes around filePath so it puts in the parameter instead of a string named "filePath".

    document.getElementById("window").data = filePath;

    david_kw


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •