passing string to javascript function with php

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
sarris
Forum Contributor
Posts: 137
Joined: Mon Dec 04, 2006 2:44 pm

passing string to javascript function with php

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

quotes...
sarris
Forum Contributor
Posts: 137
Joined: Mon Dec 04, 2006 2:44 pm

Post by sarris »

pfff....off course. its a variable without quotes.
THanks
Post Reply