What does this function do ???

Results 1 to 2 of 2

Thread: What does this function do ???

  1. #1
    IT LOVER Guest

    Default What does this function do ???

    Here is a function in javascript. Can anyone explain what exactly it does and how does it do that.<BR><BR>function parseName() {<BR> var queryString = document.location.search.substring(1);<BR> var queryArray = queryString.split("&");<BR> var pairSplit;<BR> var pairKey, pairValue;<BR> for (var i=0; i &#060; queryArray.length; i++) {<BR> pairSplit = queryArray[i].indexOf("=");<BR> if (pairSplit != -1) {<BR> pairKey = queryArray[i].substring(0,pairSplit);<BR> pairValue = queryArray[i].substring(pairSplit+1);<BR> if (pairKey == "FullName") {<BR> return(pairValue);<BR> }<BR> }<BR> }<BR> return("");<BR>}<BR><BR><BR>The function is called as :<BR>var LastName = parseName();<BR><BR>Thanks,<BR>IT Lover<BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: What does this function do ???

    Looks to me like the function is looking through a string of text and taking out a peice that it needs to input somewhere else. For instance the "&" is used as a field delimiter (marker) and the substring is used to grab a portion of the string or field.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts