use ajax to fetch the url that contains the code.
then, search the response using regexp or dom methods.
for example, i recently moved an old-school form to an ajax form, but needed a dynamic id to prevent the submitted form from being rejected.
ajax callback snip to update hard-coded form with remote value:
in that case, i was matching an input on the remote "real" page that was coded like:
<input type="hidden" name="XID" value="f2090eeb9ccccfb00714e2d377ff5a7d4127b618" />