Debt Consolidation - Free Articles Directory About Cancer - Debt Consolidation - Find jobs - Kamala Harris

PDA

View Full Version : including php variable in javascript function


bananalive
Jun 27th 2008, 9:58 am
how can i include a php variable (eg. $textstring) into javascript function

Here's the code:

<script>
function insertText() {
var textstring = "test string";
document.getElementById ("{$editorid}_iframe").contentWindow.document.body.innerHTML += textstring;
document.getElementById('vB_Editor_001_textarea').value += textstring;
}
</script>
<a href="javascript:;" onClick="insertText()">test</a>

I just want to insert $textstring instead of var textstring ($textstring which is identified in php script)

Thanks in advance,

koolman
Jun 27th 2008, 10:07 am
var textstring = "<?=$textstring ?>";

bananalive
Jun 27th 2008, 12:02 pm
thanks for your help

bananalive
Jun 27th 2008, 12:19 pm
When $textstring is more than 1 line it doesnt work, is there a way around this?

using \n doesnt work for iframes and it would make the line too long :(

EDIT: Found solution :D