/    Sign up×
Community /Pin to ProfileBookmark

How Can i Get Value from frame.location using "document.getElementById"

Hiii hello i am newbie here…i need a help with script…

[CODE]
<script type=text/javascript>
var isIE = document.all?true:false;
if (!isIE) document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = getMousePosition;
function getMousePosition(e) {
var posX;
var posY;

if (!isIE) {
posX = e.pageX;
PosY = e.pageY;
}
if (isIE) {
posX = event.clientX + document.body.scrollLeft;
posY = event.clientY + document.body.scrollTop;
}
top.leftFrame.location=’simpan.php?x=’+posX+’&y=’+posY;
document.getElementById(“coord_x”).value=’simpan.php?x=’+posX;
document.getElementById(“coord_y”).value=’simpan.php?y=’+posY;
return true;
}

</script>

<form method=”POST” action=”simpan.php”>
<input type=”hidden” name=”coord_x” id=”coord_x” value=””>
<input type=”hidden” name=”coord_y” id=”coord_y” value=””>
</form> [/CODE]

from above script i would like to collect the posX and posY and use it as value. And from that value i can post the value to database…please is my code above is right??? because i try it ….it working to get mouse position but cannot store the posX & posY into DB..it only show 0 value….and one more thing how can i use array for that code above..i mean …i would like to store maybe 100 data of posX & 100 data for posY…how can i do that..pleas someone…

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@cyber1Dec 21.2005 — Look at this and see if you can use it:

[URL=http://www.youngpup.net/_projectDirectories/domdrag/demos/domdrag/index.html]http://www.youngpup.net/_projectDirectories/domdrag/demos/domdrag/index.html[/URL]

To access frames document.getElementById:

parent.frames[1].document.getElementById('idofobject').innerHTML=myText;

This would add a value to an object.

-Bill
Copy linkTweet thisAlerts:
@sazsa6authorJan 04.2006 — emmm...i guess i dont understand and i dont have any idea how to use example that u give me...other easier way???
Copy linkTweet thisAlerts:
@jzwpJan 04.2006 — how 'bout giving the code for the frameset so I don't have to work so hard?

I mean, it looks like a fun puzzle to solve but come on...
Copy linkTweet thisAlerts:
@KorJan 04.2006 — you may:

  • 1. use GET method and give your hidden inputs directly the values posX and posY

    or

  • 2. change the action of the form, without using any hidden inputs


  • document.forms[0].action = 'simpan.php?x='+posX+'?y='+posY;
    Copy linkTweet thisAlerts:
    @sazsa6authorJan 05.2006 — this what i am doing now...it can capture the coor x and y at status bar..but cannot store it using formfield...when i check in my db it show only 0 value...

    [code=php]
    <script type=text/javascript>
    // Set Netscape up to run the "captureMousePosition" function whenever
    // the mouse is moved. For Internet Explorer and Netscape 6, you can capture
    // the movement a little easier.
    if (document.layers) { // Netscape
    document.captureEvents(Event.MOUSEMOVE);
    document.onmousemove = captureMousePosition;
    } else if (document.all) { // Internet Explorer
    document.onmousemove = captureMousePosition;
    } else if (document.getElementById) { // Netcsape 6
    document.onmousemove = captureMousePosition;
    }
    // Global variables
    xMousePos = 0; // Horizontal position of the mouse on the screen
    yMousePos = 0; // Vertical position of the mouse on the screen
    xMousePosMax = 0; // Width of the page
    yMousePosMax = 0; // Height of the page

    function captureMousePosition(e) {
    if (document.layers) {
    // When the page scrolls in Netscape, the event's mouse position
    // reflects the absolute position on the screen. innerHight/Width
    // is the position from the top/left of the screen that the user is
    // looking at. pageX/YOffset is the amount that the user has
    // scrolled into the page. So the values will be in relation to
    // each other as the total offsets into the page, no matter if
    // the user has scrolled or not.
    xMousePos = e.pageX;
    yMousePos = e.pageY;
    xMousePosMax = window.innerWidth+window.pageXOffset;
    yMousePosMax = window.innerHeight+window.pageYOffset;
    } else if (document.all) {
    // When the page scrolls in IE, the event's mouse position
    // reflects the position from the top/left of the screen the
    // user is looking at. scrollLeft/Top is the amount the user
    // has scrolled into the page. clientWidth/Height is the height/
    // width of the current page the user is looking at. So, to be
    // consistent with Netscape (above), add the scroll offsets to
    // both so we end up with an absolute value on the page, no
    // matter if the user has scrolled or not.
    xMousePos = window.event.x+document.body.scrollLeft;
    yMousePos = window.event.y+document.body.scrollTop;
    xMousePosMax = document.body.clientWidth+document.body.scrollLeft;
    yMousePosMax = document.body.clientHeight+document.body.scrollTop;
    } else if (document.getElementById) {
    // Netscape 6 behaves the same as Netscape 4 in this regard
    xMousePos = e.pageX;
    yMousePos = e.pageY;
    xMousePosMax = window.innerWidth+window.pageXOffset;
    yMousePosMax = window.innerHeight+window.pageYOffset;
    }
    top.leftFrame.location='simpan.php?xMousePos=' + xMousePos + ' ,yMousePos=' + yMousePos + ', xMousePosMax=' + xMousePosMax + ' ,yMousePosMax=' + yMousePosMax;
    document.getElementById('xMousePos').value = xMousePos;
    document.getElementById('yMousePos').value = yMousePos;


    return true;

    }

    </script>

    <form method="POST" action="simpan.php">
    <input type="hidden" name="coord_x" id="coord_x" value="xMousePos">
    <input type="hidden" name="coord_y" id="coord_y" value="yMousePos">
    </form>
    [/code]



    what wrong with script above..please...
    Copy linkTweet thisAlerts:
    @sazsa6authorJan 05.2006 — you may:

  • 1. use GET method and give your hidden inputs directly the values posX and posY

    or

  • 2. change the action of the form, without using any hidden inputs


  • document.forms[0].action = 'simpan.php?x='+posX+'?y='+posY;[/QUOTE]

    ??i still in the dusk....can u explain using my coding i have done...please
    ×

    Success!

    Help @sazsa6 spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.18,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...