View Full Version : visual display for textarea
midhul
08-01-2008, 12:43 PM
hi,
i have a textarea and a frame on my web page.
there is html code in my text area.
i need a code that can read the code in the textarea and take all the elements and their attributes
into strings. for example if there is a text box named text1 and size attttribute
as 5 then the code should make the string as text1_size = 5
then it sould display all the elements in the frame visually and make them drag n drop. when the user clicks drags and releases any element on this page, it should automatically take the x and y position to where it is dragged as strings
Jesdisciple
08-02-2008, 04:59 AM
Use a regex to define what you're looking for and how you'll react to it, then put your reaction in a draggable P/DIV/SPAN. See http://www.dynamicdrive.com/dynamicindex11/domdrag/ and http://w3schools.com/jsref/jsref_obj_regexp.aspv (http://w3schools.com/jsref/jsref_obj_regexp.asp)
If you want me to guide you, you'll need to be more specific about which attributes should be involved (just size?).
midhul
08-02-2008, 02:10 PM
I dont understand how to use regex,
can you guide me please.
Not only size but all the attributes present
Jesdisciple
08-02-2008, 04:00 PM
Then http://www.regular-expressions.info/javascript.html is more appropriate for you than the previous link.
That text is gonna get awful long... Are you sure you want every attribute shown? I think it would be hard for the user to handle the elements.
Are you sure this should be in an <iframe>? This will require one more HTML page and some extra scripting than if you were to use a <div> instead.
midhul
08-03-2008, 02:57 AM
let it be in a div!
thanks!
midhul
08-03-2008, 03:02 AM
i understood the basic of javascript regex
but i dont understand how i can use it for what i want.
Can you guide me for the script!(let it be in a div instead of an iframe)
Thanks!
midhul
08-03-2008, 03:05 AM
all the attributes should only be taken into variables.
the ones that relate to display like size and color etc. are to be shown.
in the display
Please use the edit button under your post, instead of making a new post.
Jesdisciple
08-03-2008, 04:47 AM
*cries* I just typed a nearly complete article and closed the tab. I need to write my drafts on my filesystem from now on...
Anyway, what do you mean by "taken into variables"? Please be as precise as possible.
Here's a pattern for a simple tag. Refer to the W3Schools reference for details and see how far you can go with the attribute pattern.
var regex = /^<([a-z][a-z\d]*)\s*\/?>$/mi;Every HTML tag begins with a letter, but some (AFAIK only h1-h6) have numbers after that. I also optionally included the XHTML self-closing-tag slash and the zero or more whitespace characters which some browsers require with it.
midhul
08-04-2008, 11:14 AM
it means:
if there is an attribute called size=3 of element1 then the variable called element1_size = 3 will be created
if there is another attribute called color=red
then element1_color=red
and so on...
Jesdisciple
08-04-2008, 04:42 PM
So you're saying if the user gives
<div width="300" height="400"></div>then the code should have an effect of
var [div_width="300"] = //What goes here?
var [div_height="400"] = //What goes here?Note that this code will not work, but I'm trying to understand what you're wanting. And what should be on the right side of the assignments?
EDIT: Or do you mean this?
var div = {};
div.width = "300";
div.height = "400";
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.