Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7190713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:34:29+00:00 2026-05-28T19:34:29+00:00

I have set up a little snippet that will take an autoresponder code for

  • 0

I have set up a little snippet that will take an autoresponder code for email marketing from a textarea and when the textarea loses focus, it parses what was just pasted and grabs some attributes and elements from that, and puts them in separate input fields.

The problem is that the code I’ve written apparently doesn’t do this right and for some autoresponder codes, it won’t grab the form’s action URL, some it does, it usually has no problem grabbing all of the hidden input fields, and then sometimes does not want to grab the name or email fields ‘name’ attributes.

The code is pretty straight forward. I tried using .find() instead of .filter() and it seems to just act at random. Some things work that didn’t work with .find(), some things don’t work that did work with .find(). I don’t think that’s the root of the problem but may help to explain what’s going on.

Edit It seems to work “better” with .find().

I just have no idea why it would behave like this, any ideas?

Example form HTML that is inserted to a textarea is here. (It is messy but I didn’t write it!) — This code would be in a textarea in which the code below parses it when it loses focus.

Edit: The root of the problem seems to the the <form action="#"> part.

  • An Aweber Code for example, will not retrieve the Form URL (action attribute)

  • An Ebizac Code will not retrieve the Form URL

  • An Imnica Code works fine now apparently(?).

  • There’s no problems with the GetResponse Code.

Most recent JSFiddle <- code here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T19:34:29+00:00Added an answer on May 28, 2026 at 7:34 pm

    I believe the problem with the html that doesn’t work like your AWeber example is that it is not contained within a single top-level parent element, which means that when you parse it to create the arcode jQuery object that object contains the <form> element as a top level element. That in turn means that the .find() method – which looks for descendent elements – doesn’t find anything since there are no additional <form> elements that are children. (You can test this for yourself by checking arcode.length or using arcode.each() to log the tagnames of the elements in arcode.)

    Your example that did work happened to be wrapped in a top-level <div>, so it didn’t have this problem.

    So my suggested fix for this is just to wrap the entered html in a <div> element yourself, thus making everything work with .find(). And then simplify your function, since the following short version does all that your original function did:

    $j( '#jwsqz_autocode' ).blur( function() {
    
        var thehtml = "<div>" + $j( this ).val() + "</div>";
        var arcode = $j( thehtml );
    
        $j('#jwsqz_autoformurl').val( arcode.find('form').attr('action') );
        $j('#jwsqz_arnameinput').val(
             arcode.find('input[type="text"][name*="name"]').attr('name') );
        $j('#jwsqz_aremailinput').val(
             arcode.find('input[type="text"][name*="email"]').attr('name') );
    
        var hiddens = "";
    
        arcode.find( 'input[type="hidden"]' ).each( function() {
           hiddens += $j( this ).prop( 'outerHTML' ) + "\n";
        });
    
        $j( '#jwsqz_autohidden' ).val( hiddens );
    
    });
    

    Working demo: http://jsfiddle.net/fpK9F/6/ (seems to handle your example cases).

    You’ll notice I’ve made use of the jQuery attribute contains selector with [name*="email"].

    Note that if tests like the following from your code are redundant:

    if( hiddens != '' )
       $j( '#jwsqz_autohidden' ).val( hiddens );
    else
       $j( '#jwsqz_autohidden' ).val( '' );
    

    In the else case you are setting the value that was in the hiddens variable anyway, so you can replace the whole structure with just the part from the if – as I did in my code above.

    UPDATE: For a case-insensitive test of the name attribute’s value you can do this:

        $j('#jwsqz_aremailinput').val(
             arcode.find('input[type="text"]')
                   .filter(function(){ return /email/i.test(this.name); })
                   .attr('name') );
    

    (You don’t have to use a regular expression, the key point is the .filter() function.)

    Case insensitive demo: http://jsfiddle.net/fpK9F/7/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have set up an annotation that will be used to keep track of
I have a little dilemma on how to set up my visual studio builds
I have set up a Django application that uses images. I think I have
Usually u have to set up a little script + htmlpage on your server
I have set up a little server on an old XP Pro box, with
I've got this little snippet that I use for row highlighting on an XSLT
Simple question. After a little bit of 'chmod' shenanigans, I have set the permissions
I have set up a page so that it loads content in with AJAX
So I've got a little script set up on my server that says whether
I don't have much experience doing unit testing. From what I learned, code should

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.