Click to See Complete Forum and Search --> : indexOf - arhhh!


quiksilv
05-13-2004, 10:13 AM
i have a js function that gets called from a link that should populate a txtbox with the value of the link. what i want to do is not insert the value if it already exists in the txtbox. this is what i have

<script language="JavaScript" type="text/JavaScript">
function TWS(SMS)
{
// var str = parent.SendSMS.SMSTo
if (parent.SendSMS.SMSTo.indexOf(SMS)=-1)
{
str.value = str.value + SMS + ","
}
}
</script>

any help would be great:confused:

sciguyryan
05-13-2004, 01:01 PM
Ok, the solution is simple:


<script language="JavaScript" type="text/JavaScript">
<!--
function TWS(SMS){
var box = document.getElementById("ElementID");
if (SMS.href != ""){
box.value += SMS.href;
}}
//-->
</script>


Just remember to change ElementID to the text-boxes id.

The call would go like this:

OnClick="TWS(this);"

This works, I have tested it.