|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
PHP and WUSIWUG editor
Im glad that the forums back in action and that i can finally ask this question.
You probally remember the WYSIWYG editor by mytch. Well what i was wondering, using PHP how would i upload the html from this editor to a database(mysql) or atleast convert it into a variable so that i can process it??? i think someone posted about this before, but it was lost in the transfer Thanks in advance |
|
#2
|
|||
|
|||
|
hi ben,
well it's in the content of an iframe, so just use something like var src = new string(); src = document.iFrame.document.body.innerHTML; then set a hidden form field in the parent document to the value of src: <input type="hidden" name='hiddenSrc" value=""> document.hiddenSrc.value = src; then submit the form...does that sound ok to you? |
|
#3
|
|||
|
|||
|
does that mean the variable "src" would contain all the info within the iframe? then you can use $src inside the php code?
i r stupid ![]() |
|
#4
|
|||
|
|||
|
nah,
when you submit the html form, you can then get the hiddenSrc form field variable as $hiddenSrc through PHP on the page where the form was submitted. from there you can add it to the database or do whatever else you like with it. |
|
#5
|
|||
|
|||
|
Ahh, ok. Now i get it
![]() |
|
#6
|
|||
|
|||
|
one more question:
how would i make a drop-down box with a few classes from my CSS. like .title, .blah, .bleh and then apply it to the selected text? ![]() |
|
#7
|
|||
|
|||
|
Ok im abit stuck, i changed the script to look like this
<form action="print_script.php" method="post"> <script language="JavaScript"> function getCode() { var src = iView.document.body.innerHTML; document.test.value = src; alert(src); } </script> <input type="hidden" name="test"> <input type="button" onClick="getCode();" value="update"> <input type="submit" name="submit" value="upload to DB"> </form> Now if you look at this, it look right??? wrong! click the update button, it doesnt work take out the line document.test.value = src; now the alert works anyone have any idea?????? Thanks |
|
#8
|
|||
|
|||
|
Thanks to my good friend Mytch, the problem is now solved(and i need to read my Javascript book again!)
replace the above problem line with document.all.test.value =src; Thats it, now you can send that to your asp or php page and upload it to your db, or what ever you want, in this case, im using it for a project im working on May The Force Be With You Linux Forever! |
|
#9
|
|||
|
|||
|
if i had my content in a variable called $content, how would I print it into the iframe for editing?
__________________
![]() ![]() "Only Linux users see the end of crashes." - Pl4t0 |
|
#10
|
|||
|
|||
|
sometimes it helps to give the form a name / id as well, and then do a document.formname.controlname.value. This usually does the job for me.
|
|
#11
|
|||
|
|||
|
Yay, I got it to work
! I would like to thank Ben for helping me debug my code and mytch for writing the great tutorial.![]() |
|
#12
|
|||
|
|||
|
No Problems, its good to see that your learning, and after those few hickups i hope you wont have the same problems again
|
|
#13
|
|||
|
|||
|
Hehe, thanks for reminding me on a few newbie mistakes I made. I did. "UPDATE table(field1, field2, field3); VALUES ($form1, $form2, $form3) WHERE id=$id" instead of the proper syntax "UPDATE articles SET field1= '$form1', field2='$form2', field3='$form3' WHERE id=$id";
My bad ![]() |
|
#14
|
|||
|
|||
|
hi everybody!
i am a total newbie in java script and it would be very nice if someone could post the hole code or at least the one to insert my php variable $html to the iframe. ![]() |
|
#15
|
|||
|
|||
|
ok if you have say
if you send the info from another page, one way to load it in the editor is like this. <iframe src="load.php?html=info"> create a page called load.php in it add this line <?php echo $html ?> i hope thats what your trying to do |
|
#16
|
|||
|
|||
|
I have a problem with special characters like '
when ever I use these in a sentence like hey c'mon , the text gets converted to hey c/'mon, how can I fix this in PHP? |
|
#17
|
|||
|
|||
|
There is a way,
try using this function stripslashes ($var); convert the data from the editor into a php var and parse it though that function, that should convert \' to ' and \\ to \ hope that helps |
|
#18
|
|||
|
|||
|
Insert Image
Hi to everyone
Well this happens to be my first post but i have been hanging around this place since quite some time. I am stuck on inserting images in my WYSIWYG html editor. After reading the article by Mitch and the documentation of "execCommand" at MSDN, i find myself struggling with some queries. I would appreciate if anyone could answer them. Well the first one being that i am not able to download the support files for the 2nd article where its explained on how to connect to the database. The file i am downloading succesfully as the size of 0bytes. Then i am struggling with the image insertion part. Both Mitch's article and the documentation at Microsoft explicitly says, if "InsertImage" is called with the middle parameter of "execCommand" set to true, it presents a modal dialog box to select an image. But i am not able to make it work. Mitch is using an alert box, to enable user the enter the location of image manually. What i need is to allow the guy to browse and select the image, may be just on the server and forget abt uploading at the moment. Actually i am trying to develop a HTML editor which will alow clients to upload their own images as well as select from the online server which could be a differnet domain and i am kinda stuck on that. If anyone could propose any solutions, i'd really appreciate that. Yakesh |
|
#19
|
|||
|
|||
|
|