0

I have a Yii CActiveForm backed with a CFormModel and I'm using the onChange htmlOption to call the javascript send(). The send function tweeks some of the form variables and populates a hidden field ready for form serialising and POSTing back to the server.

My problem is that I don't know how to reference the form fields from inside the javascript function using jQuery because the CActiveForm changes their names. Currently I'm having to hard code the names eg $('#SearchForm_myvar').val("myval"); which doesn't seem right. How can I reference the form variables inside the javascript code?

1 Answer 1

1

Found the answer from the source so putting it here in case someone else wants it. The jQuery id is:

"#" . CHtml::activeId($model,'myvar')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.