Rich-text Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
How can I edit onclick funtions on input fields for the variations ?
suvdeep 12-22-15
How can I edit onclick funtions on input fields for the variations ?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report
The objective is to change the behaviour/code of the onclick function on a submit button.
Highlighted
Nils_van_Kleef 12-23-15
Re: How can I edit onclick funtions on input fields for the variations ?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report
Hi there, thanks for your question!
What you can do is define a new function, and then change the attribute of the input fields to point to this new function instead of the old function, e.g. using this template:
$("#id").attr("onclick","new_function_name()");
You'll of course have to change the #id to point to the right element, and the new_function_name to the name of the new function. You can also add the code here directly instead of pointing to a function with the new code.
You can then use the code editor in the Optimizely experiment editor to add your code.
For some examples, please check these pages:
- http://stackoverflow.com/questions/4506219/how-to-change-onclick-event-with-jquery
- http://stackoverflow.com/questions/826628/javascript-changing-the-value-of-onclick-with-or-without-j...
- http://stackoverflow.com/questions/3604906/how-do-we-change-onclick-function-via-attr-in-jquery
- http://stackoverflow.com/questions/9153299/jquery-change-onclick-function-name
I hope this helps!
Nils