velocity, javascript, html

can anypne help me rectify this code, i am getting object error  every time i check on the check box.... also i am not sure about embeddeding javascript and velocity code together....


#if($!{obj.flag} == 'y')
	 
	  #set($address = "$!{obj.add}") 
 
<input name="spouseadd" id="spouseadd" type="checkbox" value="true"  onClick="findadd(this);"></td>
 
<script language="JavaScript" type="text/JavaScript">
<!--
function findadd(checkField) {
  alert('getting called');
   if(checkField.checked){
   document.myform.street1.value=$address;
   
   }
 
}
 
//-->
</script>

Open in new window

sakvkAsked:
Who is Participating?
 
hieloCommented:
I don't know what this:
document.myform.street1.value=$address;
   
is producing for you, but if the browser sees something like:
document.myform.street1.value=xyx somestreet name

then you need to quote the value so that it looks like:
document.myform.street1.value="xyx somestreet name"
0
 
Tomarse111Commented:
Presumably on your page you have a form with name myform and a input with the name street1?
0
 
sakvkAuthor Commented:
yes, i have form with name myform and street1 is there
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
sakvkAuthor Commented:
yeah...
from the velocity tag, i am getting the value of address which i am assignin to the textbox street1.
$address ='someaddress'
so
document.myform.street1.value=$address;
0
 
Tomarse111Commented:
Have you tried

document.myform.street1.value='$address';

which is what i think heilo is getting at.
0
 
hieloCommented:
>> i am assignin to the textbox street1.
$address ='someaddress'
Yes, but that is just assinging the string 'someaddress' (WITHOUT the apostrophes) to $address. But the javascript needs the quotes. You should be assigning something like:
$address ="'someaddress'"

OR alternatively:
document.myform.street1.value='$address';
0
 
hieloCommented:
>>which is what i think heilo is getting at.
Exactly.
0
 
sakvkAuthor Commented:
thanks a lot
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.