ef*****@epitome.com.sg wrote:
Yes, that's one option. I am programming in domino and I can do that
passing the "string"in an iframe and get the returned result but I was
just exploring if I can also do this with Javascript. by the way, this
operation is done by calling a O pixel iframe document.
Thanks
Here is a little script that illustrates a client-side check of the
list. Make sure you test again at the server, you can't be sure the
user has JavaScript enabled or that they aren't submitting their own
string back to your server.
I have used the option text, but you may want to use the option value
(if there is one). The match is between newline characters, you need
to select something that you put into the text area but isn't part of
the option values/text. The text area is readonly so that users
can't enter their own delimiters and mess-up the test.
You may use a comma separated set of values, but newlines may look
neater depending on what you put into the text area. Note that a
delimiter (\n) is added to the front of the string when testing, but
not used inside the text area. This should ensure you only match
entries, but please test thoroughly.
<script type="text/javascript">
function addToTA(txt,tgt){
var txtReg = new RegExp('\\n' + txt + '\\n');
if(txtReg.test('\n'+tgt.value)){
alert('You already chose ' + txt
+ '.\nSelect another value');
} else {
tgt.value += (tgt.value != '')?'\n'+txt : txt;
}
}
</script>
<form action="">
<select onchange="
addToTA(this[this.selectedIndex].value,this.form.theList)
";>
<option></option>
<option>Option 1</option>
<option>Option 2</option>
<option>Another Option 2</option>
<option>Option 22</option>
<option>Option 2 2</option>
<option>Another Option 2 2</option>
</select>
<textarea readonly name="theList" rows="10" cols="20"></textarea>
<br>
<input type="reset">
</form>
--
Rob