I’m calling a function from an input radio button and have this:
onClick=\"changeBilling('".$results['id']."', this.value)\"
But my this.value isn’t working properly. When I look it up in the page, the id is filling properly, but the second value still says this.value, and not the value of the button that is calling the function.
I see this in the browser element manager:
onclick="changeBilling('149', this.value)"
What am I doing wrong?
Radio Button:
<input type='radio' name='billed' value='Yes' onClick=\"changeBilling('".$results['id']."', this.value)\"/> Yes<br /><input type='radio' name='billed' value='No' onClick=\"changebilling('".$results['id']."', this.value)\" checked/> No
Ideal Output:
onclick="changeBilling('149', 'Yes')"
this.valuewill be evaluate by the client, as its javascrpt, so you will not see the “baked” value in there from your php, you need to check this at runtime, your best bet is to alert the value ofthis.valueand check if it is what you expect, because this is what will be passed tochangeBillingthe issue you may be getting is that
thismay not be evaluating to the thing you expect it to, to find out (if you have a good debugger like Element inspector (chrome) or firebug (firefox)) will be to put: