여러 양식 필드에서이 js 스크립트를 여러 번 사용해야합니다. 한 필드에서 훌륭하게 작동하지만 동시에 다른 필드에서이 스크립트를 사용하여 복제하는 방법을 모르겠습니다. 모든 확인란에는 RegEx 완료를 위해 미리 정의 된 값이로드됩니다. 따라서 아래의 모든 코드는 하나의 양식 필드에 속합니다. 일부 클래스 attrbiute 값을 가진 하나 개의 컨테이너에자바 스크립트 중복 ID 충돌
<head>
<!-- CHECKBOXSES REGEX 1 -->
<script type="text/javascript">
function getVal(bu){
var el=document.getElementById('col12_filter_prospective');
var i=0, c;while(c=document.getElementById('chk'+(i++)))
{el.value=(bu.checked)? bu.value : null;c!=bu? c.checked =false : null;
}
}
</script>
</head>
<body>
<input type="checkbox" name="chk" value="[^***]" id="chk0" onclick="getVal(this)" title="[^***] Replace (***) with the word to excluded from search.">
<input type="checkbox" name="chk" value="/whatever[^s]*./" id="chk1" onclick="getVal(this)" title="/whatever[^s]*./ Find (whatever) words that ends with (s) or any other combination.">
<input type="checkbox" name="chk" value="/***/" id="chk2" onclick="getVal(this)" title="/***/ Replace *** for specific word to be found.">
<br>
<input type="text" class="column_filter_prospective" name="col12_filter_prospective" id="col12_filter_prospective">
</body>
와우, 그 코드는 엉망입니다. 내가 해독 할 수있는 것으로부터, 이것은 정규 표현식과는 아무런 관련이 없습니다. 선택한 체크 박스의 값을 텍스트 상자에 복사하는 것입니까? –