www.webdeveloper.com
Results 1 to 4 of 4

Thread: Manipulating a string contained in a HTML table data

  1. #1
    Join Date
    May 2012
    Posts
    37

    Manipulating a string contained in a HTML table data

    Hi ,

    I have javascript variable (var path) which is conatining the table data of particular table row and column. Following line is the code :


    Code:
    var path = mytable.rows[i].cells[3].innerHTML;
    The 'path' variable is containing :

    <a href="coll.pl?path=/home/common/units">(/home/common/units)</a>

    My requirement is to extract the path information (i.e /home/common/units )
    from the above string. How can I do that ?

    Please help.

    Thanks.

  2. #2
    Join Date
    Mar 2009
    Posts
    452
    i don't understand what actually you need. anyway give it a try to path.split('/');

  3. #3
    Join Date
    Nov 2010
    Posts
    1,047
    you could slice the string...
    Code:
    <script>
    var path='<a href="coll.pl?path=/home/common/units">'
    var mypath=path.slice(path.lastIndexOf('=')+1,path.lastIndexOf('"'))
    alert(mypath)
    </script>

  4. #4
    Join Date
    May 2012
    Posts
    37
    Thank you xelawho. It works.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles