rockinaway Posted December 2, 2007 Share Posted December 2, 2007 I have been making a WYSIWYG and I have come across a few problems.. When I want to add some predefined text to an iframe I access the innerHTML and pass the content through a function: function preText(text) { stuff_before.innerHtml = text; } It works for some cases, but then when there are \n and brackets () present in the text I want to predefine, I get all sorts of errors like missing bracket and another weird one. What can I do to stop these from occuring? Would be a PHP function applied before I send it to the function, or Javascript changes? Quote Link to comment https://forums.phpfreaks.com/topic/79852-javascript-and-php/ Share on other sites More sharing options...
rockinaway Posted December 3, 2007 Author Share Posted December 3, 2007 Any help? Quote Link to comment https://forums.phpfreaks.com/topic/79852-javascript-and-php/#findComment-405330 Share on other sites More sharing options...
PHP_PhREEEk Posted December 3, 2007 Share Posted December 3, 2007 That function seems completely dysfunctional... (text) - text is not a variable, nor a valid argument for a function. You need a variable or an expression there. stuff_before.innerHtml = text stuff_ect. is not a variable, so it cannot be assigned text. text is not in the format of a string, so it cannot be assigned to stuff_etc. even if stuff_etc. was a valid variable. There is apparently nothing valid about this function besides its name, and I have no idea what you what it to do... my best guess is: <?php function preText($text) { $text = 'stuff_before.innerHtml'; } but even that doesn't make much sense to require the function to have a string of $text provided to it, then turn around and immediately redefine $text... /scratches head PhREEEk Quote Link to comment https://forums.phpfreaks.com/topic/79852-javascript-and-php/#findComment-405346 Share on other sites More sharing options...
grejon04 Posted December 3, 2007 Share Posted December 3, 2007 The reason it's dysfunctional is because its Javascript, not PHP... I'm not sure that PHP and JavaScript are compatible except in regards to where PHP would help with stuff like dynamic variable assigning, so a javascript question might not get answered real fast on this board... Quote Link to comment https://forums.phpfreaks.com/topic/79852-javascript-and-php/#findComment-405365 Share on other sites More sharing options...
rockinaway Posted December 6, 2007 Author Share Posted December 6, 2007 Don't worry it is fully functional.. and I fixed my problem. I was just writing it in shorthand in my post.. else it is fully functional.. Quote Link to comment https://forums.phpfreaks.com/topic/79852-javascript-and-php/#findComment-408222 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.