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 6057955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:32:43+00:00 2026-05-23T08:32:43+00:00

I’m using a simple jquery code that grabs html code form a tag and

  • 0

I’m using a simple jquery code that grabs html code form a tag and then puts this content into a form input

<td class="name_cat" ><span class="name_cat">It&#039;s a &quot;test&quot; </span> (5)</td>

jquery gets the content into span.name_catand returns it as It's a "test".
So when I print this into an input it becomes

<input value="It's a "test"" />

which as you can imagine will only show as It's a , the following double quote will close the value tag.
What’s the trick here to keep the original string while not showing utf8 code in the input?

Jquery code

            $(".edit_cat").click(function(){

            tr = $(this).parents("tr:first");
            id_cat = $(this).attr("id");
            td_name = tr.find(".name_cat");
            span_name = tr.find("span.name_cat").html();
            form = '<form action="/admin/controllers/edit_cat.php" method="post" >'+
                            '<input type="hidden" name="id_cat" value="'+id_cat+'" />'+
                            '<input type="text" name="name_cat" value="'+span_name+'" />'+
                            '<input type="submit" value="save" />'+
                            '</form>';
            td_name.html(form);

            console.log(span_name);


        }
        );

I basically need html() not to decode Utf8

  • 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-23T08:32:43+00:00Added an answer on May 23, 2026 at 8:32 am

    You can build the form the way you are now, but traverse the form object using jQuery’s context

    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.js"></script>
    
    <script type="text/javascript">
    $(function() {
        $('#go').click(function() { 
            var tester = $('<div></div>').html('It&#039;s a &quot;test&quot;');
            var form = $('<form action="/admin/controllers/edit_cat.php" method="post" >' +
                        '<input type="hidden" name="id_cat" />' +
                        '<input type="text" name="name_cat" />' +
                        '<input type="submit" value="save" />' +
                        '</form>');
            $(':hidden:first', form).attr('value', tester.text());
            $(':text:first', form).attr('value', "Some attribute");
    
            $('#output').append(form);
        });
    });
    </script>
    <input id="go" type="submit" value="click"/>
    <div id="output">
    </div>
    

    What I’ve done here is wrapped your form html input in a jQuery object as form. Then, you can query items within that object’s context using the little-used jQuery form of:

    jQuery( selector, [context] )
    selector: string containing a selector expression
    context: DOM Element, Document, or jQuery to use as context

    edit: I created a tester object and set the content to your html example. Then, when I set the value in the hidden input, I call .text() to get the non-html representation. The value is the same as you’d expect.

    <form action="/admin/controllers/edit_cat.php" method="post">
        <input type="hidden" name="id_cat" value="It's a &quot;test&quot;">
        <input type="text" name="name_cat" value="Some attribute">
        <input type="submit" value="save">
    </form>
    

    You’d have to decode this html on the backend, though. This is probably the best you’d be able to do because XML doesn’t allow ‘escaping’ quotes like "\"this\"". The specification requires quotes to be escaped like &quot;this&quot;.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I'm making a simple page using Google Maps API 3. My first. One marker
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have just tried to save a simple *.rtf file with some websites and

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.