The problem is, this is in the onblur of a zipcode text field. Where it says zip=, I need to put something following the equal sign that will cause the eventual generated javascript to send the value of the text field. I've tried having :
this.value
'this.value'
'this.value'
+this.value+
all not working. The ajax call ends up sending the string 'this.value' as the data.
No joy. I have tried zip=js:this.value, zip='+js:this.value+', zip='js:this.value', and zip='+js:this.value+', among others.
Looking at the ajax trace in firebug, in one case zip= will not be sent at all, in all the other cases, what is sent is what is shown, for example, the ajax params will have:
zip js:this.value
or
zip +js:this.value+
I know there must be some way to send the contents of a form field through ajax, but my mind shuts down when I start thinking, “this is a php call, and I’m concerned about sending a value via javascript, and that value doesn’t exist at the time that the php is being evaluated, but the php needs to put something in the javascript it creates so that javascript will then evaluate IT and …” yikes.
If so, I'm still left with what I pass as the value side of the 'zip' key, so that when the page is eventually rendered, the javascript will take the value of the text field at that time and plug it into the array.
One more question. If I want the onblur to have a javascript 'if' statement, such as onblur:if(this.value.length==5){ ajax call, how would I do that? I tried putting
'onblur'=>'if(this.value.length==5){'.CHtml::ajax… but that doesn't seem to be it.