skip to Main Content
<input id="WD01B3" ct="CB" lsdata="{2:'WD01B4',4:'Any',20:'x7bx22WDA_TYPEx22x3ax22DROPDOWN_BY_KEYx22,x22WDA_IDx22x3ax22ABCA950297D2C0C432BAB9BBF5A1BB48.07.MAINVIEW._0120x22,x22ENABLEDx22x3ax22Xx22,x22KEYSx22x3ax5bx7bx22keyx22x3ax22x22,x22valuex22x3ax22Anyx22x7d,x7bx22keyx22x3ax22ACx22,x22valuex22x3ax22Actionx22x7d,x7bx22keyx22x3ax22APx22,x22valuex22x3ax22Applicationx22x7d,x7bx22keyx22x3ax22CAx22,x22valuex22x3ax22Catalogx22x7d,x7bx22keyx22x3ax22DOx22,x22valuex22x3ax22Datax20Objectx22x7d,x7bx22keyx22x3ax22EXx22,x22valuex22x3ax22Expressionx22x7d,x7bx22keyx22x3ax22ETx22,x22valuex22x3ax22Expressionx20Typex22x7d,x7bx22keyx22x3ax22FIx22,x22valuex22x3ax22Filterx22x7d,x7bx22keyx22x3ax22FUx22,x22valuex22x3ax22Functionx22x7d,x7bx22keyx22x3ax22RUx22,x22valuex22x3ax22Rulex22x7d,x7bx22keyx22x3ax22RSx22,x22valuex22x3ax22Rulesetx22x7dx5d,x22VISIBLEx22x3ax2202x22,x22WIDTHx22x3ax22100pxx22,x22SCRIPT_METHODSx22x3ax7bx22setBackgroundColorx22x3ax22clientx22,x22setBorderColorx22x3ax22clientx22,x22setBorderRadiusx22x3ax22clientx22,x22setBorderStylex22x3ax22clientx22,x22setBorderWidthx22x3ax22clientx22,x22setFontColorx22x3ax22clientx22,x22setFontFamilyx22x3ax22clientx22,x22setFontSizex22x3ax22clientx22,x22setFontStylex22x3ax22clientx22,x22setFontWeightx22x3ax22clientx22,x22setTextDecorationx22x3ax22clientx22x7dx7d'}" lsevents="{Select:[{ResponseData:'delta',ClientAction:'submit'},{}]}" type="text" autocomplete="off" tabindex="0" ti="0" class="lsField__input" readonly="" value="Any" aria-roledescription="Select" aria-haspopup="listbox" aria-describedby=" ARIA_CB_TUT" aria-readonly="false" style="width:100px;">

Requirement: Extract ABCA950297D2C0C432BAB9BBF5A1BB48.07.MAINVIEW._0120 from the above HTML Element data.

I have ABCA950297D2C0C432BAB9BBF5A1BB48.07.MAINVIEW., how can I get the remaining string/number using JavaScript?

2

Answers


  1. Using REGEX you can get the string in between WDA_ID and the x22 immediately after.

    const WD01B3 = document.querySelector("#WD01B3");
    
    lsdata = WD01B3.getAttribute("lsdata")
    const matches = lsdata.match(/WDA_ID\x22\x3a\x22(.*?)\x22/);
    let ID = matches[1]
    console.log(ID)
    <input id="WD01B3" ct="CB" lsdata="{2:'WD01B4',4:'Any',20:'x7bx22WDA_TYPEx22x3ax22DROPDOWN_BY_KEYx22,x22WDA_IDx22x3ax22ABCA950297D2C0C432BAB9BBF5A1BB48.07.MAINVIEW._0120x22,x22ENABLEDx22x3ax22Xx22,x22KEYSx22x3ax5bx7bx22keyx22x3ax22x22,x22valuex22x3ax22Anyx22x7d,x7bx22keyx22x3ax22ACx22,x22valuex22x3ax22Actionx22x7d,x7bx22keyx22x3ax22APx22,x22valuex22x3ax22Applicationx22x7d,x7bx22keyx22x3ax22CAx22,x22valuex22x3ax22Catalogx22x7d,x7bx22keyx22x3ax22DOx22,x22valuex22x3ax22Datax20Objectx22x7d,x7bx22keyx22x3ax22EXx22,x22valuex22x3ax22Expressionx22x7d,x7bx22keyx22x3ax22ETx22,x22valuex22x3ax22Expressionx20Typex22x7d,x7bx22keyx22x3ax22FIx22,x22valuex22x3ax22Filterx22x7d,x7bx22keyx22x3ax22FUx22,x22valuex22x3ax22Functionx22x7d,x7bx22keyx22x3ax22RUx22,x22valuex22x3ax22Rulex22x7d,x7bx22keyx22x3ax22RSx22,x22valuex22x3ax22Rulesetx22x7dx5d,x22VISIBLEx22x3ax2202x22,x22WIDTHx22x3ax22100pxx22,x22SCRIPT_METHODSx22x3ax7bx22setBackgroundColorx22x3ax22clientx22,x22setBorderColorx22x3ax22clientx22,x22setBorderRadiusx22x3ax22clientx22,x22setBorderStylex22x3ax22clientx22,x22setBorderWidthx22x3ax22clientx22,x22setFontColorx22x3ax22clientx22,x22setFontFamilyx22x3ax22clientx22,x22setFontSizex22x3ax22clientx22,x22setFontStylex22x3ax22clientx22,x22setFontWeightx22x3ax22clientx22,x22setTextDecorationx22x3ax22clientx22x7dx7d'}" lsevents="{Select:[{ResponseData:'delta',ClientAction:'submit'},{}]}" type="text" autocomplete="off" tabindex="0" ti="0" class="lsField__input" readonly="" value="Any" aria-roledescription="Select" aria-haspopup="listbox" aria-describedby=" ARIA_CB_TUT" aria-readonly="false" style="width:100px;">
    Login or Signup to reply.
  2. What about getting the the element by ID WD01B3 — Grabbing the lsdata as string — Convert that to object and do it natively?

    var js = {2:'WD01B4',4:'Any',20:'x7bx22WDA_TYPEx22x3ax22DROPDOWN_BY_KEYx22,x22WDA_IDx22x3ax22ABCA950297D2C0C432BAB9BBF5A1BB48.07.MAINVIEW._0120x22,x22ENABLEDx22x3ax22Xx22,x22KEYSx22x3ax5bx7bx22keyx22x3ax22x22,x22valuex22x3ax22Anyx22x7d,x7bx22keyx22x3ax22ACx22,x22valuex22x3ax22Actionx22x7d,x7bx22keyx22x3ax22APx22,x22valuex22x3ax22Applicationx22x7d,x7bx22keyx22x3ax22CAx22,x22valuex22x3ax22Catalogx22x7d,x7bx22keyx22x3ax22DOx22,x22valuex22x3ax22Datax20Objectx22x7d,x7bx22keyx22x3ax22EXx22,x22valuex22x3ax22Expressionx22x7d,x7bx22keyx22x3ax22ETx22,x22valuex22x3ax22Expressionx20Typex22x7d,x7bx22keyx22x3ax22FIx22,x22valuex22x3ax22Filterx22x7d,x7bx22keyx22x3ax22FUx22,x22valuex22x3ax22Functionx22x7d,x7bx22keyx22x3ax22RUx22,x22valuex22x3ax22Rulex22x7d,x7bx22keyx22x3ax22RSx22,x22valuex22x3ax22Rulesetx22x7dx5d,x22VISIBLEx22x3ax2202x22,x22WIDTHx22x3ax22100pxx22,x22SCRIPT_METHODSx22x3ax7bx22setBackgroundColorx22x3ax22clientx22,x22setBorderColorx22x3ax22clientx22,x22setBorderRadiusx22x3ax22clientx22,x22setBorderStylex22x3ax22clientx22,x22setBorderWidthx22x3ax22clientx22,x22setFontColorx22x3ax22clientx22,x22setFontFamilyx22x3ax22clientx22,x22setFontSizex22x3ax22clientx22,x22setFontStylex22x3ax22clientx22,x22setFontWeightx22x3ax22clientx22,x22setTextDecorationx22x3ax22clientx22x7dx7d'}
    
    
    var WD = JSON.parse(js['20']).WDA_ID
    console.log ( WD  );
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search