JSFiddle - React, Tailwind, and code Playground

by Aakash Chakravarthy

HTML

<form name="theForm">
<input type="text" name="color1" /><a href="#"onclick="return openColorPicker(document.theForm.color1)">changecolor</a><br />
<input type="text" name="color2" /><a href="#"onclick="return openColorPicker(document.theForm.color2)">changecolor</a>
</form>
<script type="text/javascript">
    function openColorPicker(targetField){
    var w = window.open('http://google.com/','color_popup','width=610,height=550,scrollbars=1');
  w.targetField = targetField; //create target field variable in popup window with the passed targetField as value
  w.focus();
  return false;
}

//callback function
function setTargetField(targetField, color){
  if (targetField){
    targetField.value = color;
  }
  window.focus();
}
</script>