www.webdeveloper.com
Results 1 to 3 of 3

Thread: Add parent form action from child

  1. #1
    Join Date
    Feb 2013
    Posts
    2

    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.

    Here are variations I've tried in the child now which did not work:
    Code:
    window.parent.document.forms['stopForm'].action = "command_stop_15264.cgi";
    
    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 and I tried a couple of options:
    Code:
    <form method="POST" name="stopForm" id="stopForm" target="stopinfo"></form>
    
    <form method="POST" action="" name="stopForm" id="stopForm" target="stopinfo"></form>

  2. #2
    Join Date
    Mar 2009
    Posts
    478
    If I understand you correctly, do the following:
    (1) Add an input of type "hidden" to your form.
    (2) Add to, or create, an 'onsubmit' event to that form
    (3) on submit, access the element from the iframe and extract its value
    (4) put the value inside the hidden input
    (5) have onsubmit return "true"

  3. #3
    Join Date
    Feb 2013
    Posts
    2
    tcob, yes that would work, put my value from the child to a hidden input of the parent form.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles