SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2007
    Posts
    54
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Append enctype="multipart/form-data" to form

    Hello,

    I suck big time with Javascript and really would need your help right now. I am building a Wordpress plugin and trying to assign an enctype="multipart/form-data" to write posts form without altering the original application core code.

    I am trying this approach and have no results so far (also tried with document.getElementById("post"))

    var theForm = document.getElementsByName("post");
    theForm.setAttribute("enctype", "multipart/form-data");

    Would really appreciate your advice.

    Thanks a mil!

    Best,
    rem.

  2. #2
    SitePoint Zealot Mattinblack's Avatar
    Join Date
    May 2009
    Posts
    105
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    See this Simple AJAX page which has an example of how to set up for POST and also how to send data to a PHP form - code here is free to use.

  3. #3
    SitePoint Enthusiast
    Join Date
    Aug 2007
    Posts
    54
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Mattinblack View Post
    See this Simple AJAX page which has an example of how to set up for POST and also how to send data to a PHP form - code here is free to use.
    Thank you, will definitively have a look!

  4. #4
    SitePoint Enthusiast
    Join Date
    Aug 2007
    Posts
    54
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The code above is cool, will definitively use it for another purposes, thank you. What I was looking for though is:

    HTML Code:
    <script type="text/javascript">
    window.onload = function(){
    document.getElementById('post').enctype = 'multipart/form-data';
    		}
    </script>
    Just in case someone else might need it as well...

  5. #5
    SitePoint Member
    Join Date
    Jul 2009
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes that works perfectly. thanks for this. I was looking everywhere on how to change the form attributes and this is the only thing that works


Tags for this Thread

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
  •