Do you mean you have this function definition in your view file which is tmpForm.php? This looks weird to me. I also don't understand what you are trying to do here.
I think putting those js code in a model is not a good idea. Model should be mainly dealing with data, while these js are for presentational purpose.
Your js also contain some PHP variables which I have no clue about. Since Yii has built-in support for jquery, it would be much easier to use jquery to update a div. For example:
putting anything that is displayed in a controller or model violates MVC conventions, also down the road you might have to edit it and relearn where everything is.