Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

field contains other field value

Status
Not open for further replies.

DoctorGonzo

Programmer
Jan 23, 2004
48
0
0
GB
HI guys,

Can anyone tell me how to look for a field value within another field?

I want to check if a field value is already contained within a multivalie field.

Any help much appreciated

Gonzo
 
>...within a multivalie field.
For instance?
 

What is a multivalue field? Do you mean a select box with the multiple attribute? Or do you mean a text field which happens to have data in it that you have formatted to be able to delimit values... or something else entirely?

Dan


[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]

 
Hi guys,

here uis the field (called CrewIDs) when I do VIEW SOURCE

<INPUT NAME="CrewIDs" TYPE=hidden VALUE="7878; 1414">

I have another fiedls called CREW.. I want to write a function that checks if CREW is inside CrewIDs - say for example if I type "7878" into CREW, it will return TRUE (because "7878" id onf of the values in CrewIDs)

hope this helps
 
So you really want to test for the presence of a substring within a string. The "multivalue" field you talk about is a simple text field that (as I guessed) you have chosen to store delimited text in.

You can do this with the "indexOf" method of the String object. It returns -1 if the substring is not found, the starting position (0-based) otherwise:

Code:
var somePos = stringToSearch.indexOf('stringToFind');

Hope this helps,
Dan

[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top