SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2005
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    javascript document root or parent ?

    hi all..

    I have an html that has a form for example

    <form method=post action=blah.html>
    <input type=hidde name=myHiddenVar value=''>

    blah blah blah

    <iframe name=myiFrame frameborder=0 scrolling=no src="anypage.php">currently loading</iframe>

    </form>
    now in iFrame page (anypage.php) I want a button to control or SET the value of the main FORM (html page) and its variable myHiddenVar, for example here is what I tried and it didnt work...

    in anypage.php I hade a button
    <input type=button value=change onClick="Javascript:parent.myHiddenVar=100">

    but the aboue didnt work, is there anything like docuemtroot ? please help here..

    thanks for taking time to read tihs quesiton.
    Last edited by janu; May 21, 2007 at 04:21. Reason: disabled smilies in code..

  2. #2
    SitePoint Enthusiast Tygatur's Avatar
    Join Date
    Apr 2006
    Location
    Germany
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs down

    I'm sorry to say this, but your code is really bad practise.
    You should look for a better HTML tutorial.

    Always use "" with your HTML Attributes !

    It should be <input type="hidden" name="myHiddenVar" id="myHiddenVar" />

    And your button should look like this:

    <input type="button" value="change" onclick="parent.document.getElementById('myHiddenVar').value=100" />
    to code or not to code ?
    that's too much of a question for a signature.


Bookmarks

Posting Permissions

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