#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    2
    Rep Power
    0

    Add parent form action from child


    I am not the greatest on javascript and was hoping someone could give me some help. I am trying to pass to the parent form action field a value from the child. The child is an iframe and they are both in the same domain.

    The line I have in the child now which is not working is:
    Code:
    window.parent.document.forms['stopForm'].action = "command_stop_15264.cgi";
    I have also tried:
    Code:
    window.parent.document.forms['stopForm'].form.action = "command_stop_15264.cgi";
    window.parent.document.forms['stopForm'].form.action.value = "command_stop_15264.cgi";

    My parent page form is pretty simply:
    Code:
    <form method="POST" name="stopForm" id="stopForm" target="stopinfo"></form>
    Also tried:
    Code:
    <form method="POST" action="" name="stopForm" id="stopForm" target="stopinfo"></form>
  2. #2
  3. A Not To Shabby Code Smurf
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Aug 2008
    Posts
    1,040
    Rep Power
    119
    Do a online search for "same domain iframe communication"; that should give you some good examples of how this is done, but if your testing locally; your going to run into security errors (just so you know in advance).
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    2
    Rep Power
    0
    I figured out a way, from the child I send a value to a hidden input on the parent. Worked like a charm.

IMN logo majestic logo threadwatch logo seochat tools logo