I want to click a button which sends the name of an input field to the function. From there I want the function to take the value of that input field, split it by the "/" symbol, take the last field in the array, check to see if it is already part of a different textarea field name extra_field[4], and if not, add it to the end of that field. Here is what I have so far:
Expand|Select|Wrap|Line Numbers
- <form name="new_product">
- My input field:
- <input type=text name=test><button onclick="colors(test)">run colors on test</button>
- <script language="JavaScript">
- <!--
- function colors(blob) {
- var blob2=document.forms["new_product"].blob.value;
- var blob3=blob2.split("/");
- iname=blob3[(blob3.length-1)];
- if(blob=="clear") document.forms["new_product"].extra_field[4].value="";
- else {
- if(document.getElementById('extra_field[4]').value == "") // nothing in there
- document.forms["new_product"].extra_field[4].value="runpictures:," + iname;
- if(document.getElementById('extra_field[4]').value.search(iname) == "-1")//not found so add
- document.forms["new_product"].extra_field[4].value=document.forms["new_product"].extra_field[4].value + "," + iname;
- }
- }
- //-->
- </script>
- <textarea name="extra_field[4]"></textarea>
- </form>