Debt Consolidation - Layouts Myspace - Calendar news - Free All Ebook PDF Download - Free Credit Report

PDA

View Full Version : concatenate string


darkmunk
Oct 20th 2007, 4:50 am
I am trying to put the value of a checkbox into a text field or remove it if it is unchecked, the code below is heavily commented because I am trying to work down thru it to find the error - object doesn't support this method or property.
<input name="CD" type="checkbox" id="CD" value="CD" onMouseUp="keyPoints('CD')">
<input name="CC" type="checkbox" id="CC" value="CC">
<input name="L" type="checkbox" id="L" value="L">
<input name="AC" type="checkbox" id="AC" value="AC">

<input name="keyPoints" type="text" value="">

<script language="JavaScript" type="text/JavaScript">
function keyPoints(thisCheckbox){
alert(thisCheckbox);
//str = document.frmSend.keyPoints.value;
//alert(str);
//if (str(indexOf(thisCheckbox))<0){
//alert("enpty");
//str = str + thisCheckbox;
//}
}
</script>
Any thoughts?

Mike H.
Oct 20th 2007, 5:22 am
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Any Title</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript">

function toggleKeys(nBox){

var nKeys = document.forms[0]['keyPoints'];
nBox.checked ? nKeys.value += nBox.value + " " : nKeys.value = nKeys.value.replace(nBox.value, "");
nKeys.value = nKeys.value.replace(/^\s+/,"").replace(/\s{2,}/g," ");
}

</script>
<style type="text/css">

body {background-color:#eae3c6;margin-top:60px}
form {width:620px;margin:auto;font-family:times;font-size:12pt}
fieldset {width:610px;background-color:#f0fff0;border:1px solid #87ceeb}
legend {font-family:times;font-size:14pt;color:#00008b;background-color:#87ceeb;padding-left:3px;padding-right:3px;margin-bottom:5px}
label {display: block}
.submitBtn {font-family:tahoma;font-size:10pt;display:block;margin-left:auto;margin-right:auto;margin-top:5px;margin-bottom:5px}

</style>
</head>
<body>
<form action="">
<fieldset>
<legend>Form</legend>

<label>CD: <input type="checkbox" name="CD" value="CD" onclick="toggleKeys(this)"></label>
<label>CC: <input type="checkbox" name="CC" value="CC" onclick="toggleKeys(this)"></label>
<label>L: <input type="checkbox" name="L" value="L" onclick="toggleKeys(this)"></label>
<label>AC: <input type="checkbox" name="AC" value="AC" onclick="toggleKeys(this)"></label>

<label>Key Points: <input type="text" name="keyPoints" size="10" readonly></label>

<input type='submit' name='submit' value="Submit" class='submitBtn'>
</fieldset>
</form>
</body>
</html>

darkmunk
Oct 20th 2007, 5:29 am
Excelent, thanks Mike, works a treat.:)