10-29-2009, 08:50 PM
|
#1 (permalink)
|
|
The Acquainted
Join Date: May 2009
Posts: 178
Thanks: 9
|
Building Javascript PHP problem
Hi I'm having difficulty with a display class i've created and how it prints out javascript. I am finding that when i build the javascript using a method in the class then call the method to print out the javascript when building the page html the javascript subsequently wont work however when i simply include the same javascript from an include file i can get exactly the same javascript to work. I'm sure its how its displaying as html but dont know how to resolve or control how the browser formats it. Any guidance?
Here's how the javascript looks in the include file (this works):
PHP Code:
<script language='javascript'>
function inviteFormVerifyMe(){
var msg='';
if(document.getElementById('email').value==''){
msg+='- Email\n\n';}
if(document.getElementById('retypeemail').value==''){
msg+='- Retype Email\n\n';}
if(msg!=''){
alert('The following fields are empty or invalid:\n\n'+msg);
return false
}else{
return true }
}
</script>
Here's how it looks when produced by the php class and the html is viewed in the browser (it doesnt work):
PHP Code:
<script language='javascript'>function inviteFormVerifyMe(){var msg='';if(document.getElementById('email').value==''){msg+='- Email
';}if(document.getElementById('retypeemail').value==''){msg+='- Retype Email
';}if(msg!=''){alert('The following fields are empty or invalid:
'+msg);return false}else{return true}}</script>
|
|
|
|