How to dynamically change the script src by taking user value from user input?

  dynamic, input, javascript

I’m trying to dynamically change the <script src=oldValue"/> InputValue depends on what user types in input and after submitting page will reload with new <script src=newValue"/>

<input type="text" id="text" />
<input type="button" id="btn" value="Submit" onClick="javascript: window.open('http://www.mywebsite.com/print/' + document.getElementById('text').value);" />


<script src="//script.ashx?company=InputValue" async></script>

Source: Ask Javascript Questions

LEAVE A COMMENT