locked
Translate a code from vbscript to jscript - missing methods RRS feed

  • Question

  • Hey everybody,

    first of all. I'm a german guy and if I have some mistakes in my sentences: Sorry for that. I have the following code from an existing form:

    Sub XDocument_OnLoad(eventObj)
    strPath = XDocument.URI
    strFileName = Right (strPath, Len(strPath) - InStrRev(strPath, "/"))
    strFileName = Left(strFileName, Len(strFileName) - 4)

    dim oInfo set oInfo = XDocument.DOM.selectSingleNode("/my:meineFelder/my:ID")
    oInfo.text = strFileName
    End Sub

     And now I must change the code language to jscript and I already tried to do that:

    function XDocument::OnLoad(eventObj)
    {
    var strPath = XDocument.URI;
    var strFileName  = ...
    strFileName =...

    var oInfo = XDocument.DOM.selectSingleNode("/my:meineFelder/my:ID");
    oInfo.text = strPath;
    }

    As you can see on my attempt, I don't know how to translate the lines "strFileName = ...". Could someone of you maybe help me?

     

    best regards
    Daniel
    Thursday, September 22, 2011 9:41 AM

All replies

  • Use the string.substr() method to replace Left() and Right()

    -> substr(startindex, length)

    User string.lastIndexOf() to replace InStrRev

    -> strPath.lastIndexOf("/")


    Wir machen Termine. www.instyler.de
    Monday, September 26, 2011 8:31 AM