Hi, I currently have this code below which when I change the value in the dropdown list (id=changer) the value in the textbox also changes, try it out you'll see what I mean. As you can see "TEXTHERE" appears each time. Now say I need to use this script more than once on the same page, but with a different word instead of "TEXTHERE" each time. How would I go about doing this without having to write a seperate script each time? Sorry if you don't understand, I found it quite hard to explain. Would really appreciate any help, Thank you <script type="text/javascript"> function change( txtBox ) { var changer = document.getElementById('changer'); if(changer.value != "1"){document.getElementById('ref').value = 'TEXTHERE{$encode}';}else{document.getElementById('ref').value = 'TEXTHERE{$signin_username}';} } </script> <select id='changer' onclick="change(this);" > <option value="1">{$signin_username}</option> <option value="2">{$encode}</option> </select> <input type="text" value="TEXTHERE{$signin_username}" readonly="readonly" id="ref" onclick="document.getElementById('ref').select();" /> HTML:
<script type="text/javascript"> function change( txtBox, resp_str ) { var changer = document.getElementById('changer'); if(changer.value != "1"){document.getElementById('ref').value = resp_str + '{$encode}';}else{document.getElementById('ref').value = resp_str + '{$signin_username}';} } </script> <select id='changer' onclick="change(this, 'lol wut');" > <option value="1">{$signin_username}</option> <option value="2">{$encode}</option> </select> <input type="text" value="TEXTHERE{$signin_username}" readonly="readonly" id="ref" onclick="document.getElementById('ref').select();" /> HTML: this script will do the same thing, except that it will show "lol wut" instead of "TEXTHERE". the line onclick="change(this, 'lol wut');" Code (markup): is the one where you can set the string to a different value