Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
110
rated 0 times [  111] [ 1]  / answers: 1 / hits: 17464  / 14 Years ago, thu, august 26, 2010, 12:00:00

I'm working on a website where users can create and save their own HTML forms. Instead of inserting form elements and ids one by one in the database I was thinking to use js (preferably jquery) to just get the form's HTML (in code source format) and insert it in a text row via mysql.



For example I have a form in a div



<div class=new_form>
<form>
Your Name:
<input type=text name=something />
About You:
<textarea name=about_you></textarea>
</form>
</div>


With js is it possible to get the raw HTML within the new_form div?


More From » jquery

 Answers
5

To get all HTML inside the div



$(.new_form).html()


To get only the text it would be



$(.new_form).text()


You might need to validate the HTML, this question might help you (it's in C# but you can get the idea)


[#95790] Wednesday, August 25, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jenamackennac

Total Points: 304
Total Questions: 110
Total Answers: 107

Location: Ecuador
Member since Thu, Jun 4, 2020
4 Years ago
jenamackennac questions
Fri, Feb 18, 22, 00:00, 2 Years ago
Wed, Apr 21, 21, 00:00, 3 Years ago
Thu, Apr 1, 21, 00:00, 3 Years ago
Tue, Feb 2, 21, 00:00, 3 Years ago
;