For this you will need to work you need 2 (3) extensions:
- Button free (included with the core package since Seblod 3.8)
- Custom link
- Javascript field from Code pack (only needed for GroupX version)
For normal form
- Add field that will provide id for the link, e.g. select dynamic or joomla article.
- Add Button Free and select Custom for Link, then click on small arrow on the bottom right and add the following javascript to the Javascript(JS) field:
$('#id_for_view').change(function() { var artId = $(this).val(); var target = 'index.php?option=com_content&view=article&id=' + artId; $('#my_button').attr('onclick', "window.open('" + target + "','_blank')") }) $('#id_for_view').change();
Replace all instances of id_for_view with the name of your field that provides id and the same with my_button, replace it with name of your button (don't change # prefix)
For GroupX form
All field names involved need to be
without underscores, especially the name of parent (groupX) field, otherwise bellow javascript won't work
- On the child form: add field that provides id and Button Free as described above, just don't add any javascript to Button free, we need to put it to the parent form.
- On the parent form: add javascript field and add bellow code to it, as in normal form replace idforview and mybutton with your field names.
$('body').on('change', "[id$='idforview']", function() { var artId = $(this).val(); var myId = $(this).attr('id'); var target = 'index.php?option=com_content&view=article&id=' + artId; var ids = myId.split('_'); $('#' + ids[0] +'_'+ ids[1] + '_mybutton').attr('onclick', "window.open('" + target + "','_blank')") }) $("[id$='idforview']").change();