Page 1 of 1

passing string to javascript function with php

Posted: Thu Mar 08, 2007 12:13 pm
by sarris
Hi there, i have an issue with passing string to a javascript function

I am calling a function on a onchange event...

Code: Select all

<input name='checkbox_ad' type='checkbox' value='checkbox' checked='checked' onchange = 'changeContentAD(<?php echo $address?>)'/>
The function is that

Code: Select all

function changeContentAD(y){
	if(document.form1.checkbox_ad.checked==false){
		var x=document.getElementById('myTable').rows[0].cells
		x[0].innerHTML= ''
	}
	if(document.form1.checkbox_ad.checked==true){
		var x=document.getElementById('myTable').rows[0].cells
		x[0].innerHTML= 'ADDRESS' + y
	}
}
$address is a string...

It works fine if i pass a php variable that is an integer or if i pass a string like this

Code: Select all

changeContentAD("This is a string")'/>
Any ideas?

Posted: Thu Mar 08, 2007 12:44 pm
by feyd
quotes...

Posted: Thu Mar 08, 2007 2:45 pm
by sarris
pfff....off course. its a variable without quotes.
THanks