Jump to content

Javascript and PHP


rockinaway

Recommended Posts

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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...
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.