antonyfal Posted March 11, 2012 Share Posted March 11, 2012 Hi i have an error in my script syntax error where it is marked.. can you assist? $xhtml .= '<script>'; $xhtml .= 'function OnViewChanged(view)'; $xhtml .= '{'; $xhtml .= ' var ele = document.getElementById("callback");'; $xhtml .= ' ele.style.display="block";'; $xhtml .= ' elsif (view=="upload") ;ele.innerHTML="'.htmlentities(get_config('msg.upload',''),ENT_QUOTES,'UTF-8').'";'; $xhtml .= ' elsif (view=="manual") ;ele.innerHTML="'.htmlentities(get_config('msg.manual',''),ENT_QUOTES,'UTF-8').'";'; $xhtml .= ' elsif (view=="login") ;ele.innerHTML="'.htmlentities(get_config('msg.login',''),ENT_QUOTES,'UTF-8').'";'; $xhtml .= ' elsif (view=="contacts") ;ele.innerHTML="'.htmlentities(get_config('msg.contacts',''),ENT_QUOTES,'UTF-8').'";'; $xhtml .= ' elsif (view=="captcha") ;ele.innerHTML="'.htmlentities(get_config('msg.captcha',''),ENT_QUOTES,'UTF-8').'";'; $xhtml .= ' elsif (view=="bookmark") ;ele.innerHTML="'.htmlentities(get_config('msg.bookmark',''),ENT_QUOTES,'UTF-8').'";'; $xhtml .= ' elsif (view=="finished") ;ele.innerHTML="'.htmlentities(get_config('msg.finished',''),ENT_QUOTES,'UTF-8').'";'; // syntax error here?? $xhtml .= ' else ele.style.display="none";'; $xhtml .= '}'; $xhtml .= '</script>'; Quote Link to comment https://forums.phpfreaks.com/topic/258672-javascript-syntax-error/ Share on other sites More sharing options...
trq Posted March 11, 2012 Share Posted March 11, 2012 Post the outputed JavaScript rather than the php that creates it. Quote Link to comment https://forums.phpfreaks.com/topic/258672-javascript-syntax-error/#findComment-1326055 Share on other sites More sharing options...
trq Posted March 11, 2012 Share Posted March 11, 2012 This could also be written a lot cleaner by using a loop, but that's a php issue. Quote Link to comment https://forums.phpfreaks.com/topic/258672-javascript-syntax-error/#findComment-1326056 Share on other sites More sharing options...
antonyfal Posted March 11, 2012 Author Share Posted March 11, 2012 Hi, thanks for the replying.. here is the outputed Script.. Error: syntax error Source Code: function OnViewChanged(view){ var ele = document.getElementById("callback"); ele.style.display="block"; elsif (view=="upload") ;ele.innerHTML=""; elsif (view=="manual") ;ele.innerHTML=""; elsif (view=="login") ;ele.innerHTML=""; elsif (view=="contacts") ;ele.innerHTML=""; elsif (view=="captcha") ;ele.innerHTML=""; elsif (view=="bookmark") ;ele.innerHTML=""; elsif (view=="finished") ;ele.innerHTML=""; //error is here else ele.style.display="none";} Quote Link to comment https://forums.phpfreaks.com/topic/258672-javascript-syntax-error/#findComment-1326088 Share on other sites More sharing options...
cpd Posted March 11, 2012 Share Posted March 11, 2012 It looks like you've got errors throughout the entire script. WTF is "elsif"? And why are you repeatedly using it even though there is no if statement in the first place? Or am I going bonkers and there is some weird elsif statement? Quote Link to comment https://forums.phpfreaks.com/topic/258672-javascript-syntax-error/#findComment-1326193 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.