0

My html code looks like this

<input type="text" class="bk-i bk-fill-parent" id="loginField" name="loginSGizS" autocomplete="off" maxlength="20">

I want to get what's inside name=" " which is loginSGizS, now I see the obvious way is by input id, but I can't quite figure it out

UPDATE: I'm using this inside a php file with curl and I kind of need to keep everything within that file. What I tried so far

<?php       $home = curl('https://website.com'); $oDom = new simple_html_dom(); $oDom->load($home); $elements = $oDom->getElementById("loginField"); foreach($elements as $element){ echo $element->getAttribute('name'); }

UPDATE: I used regex $pattern = '/<input (?=[^>]* id="loginField" name=["]([^"]*)|)/ms'; and it works, thank y'all

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
Timo
  • 35
  • 6
  • Possible duplicate of [How to get element by classname or id](https://stackoverflow.com/questions/23609171/how-to-get-element-by-classname-or-id) – Hammer Jan 06 '19 at 03:10

2 Answers2

1
document.getElementById("loginField").getAttribute("name")
M. Duisenbayev
  • 309
  • 1
  • 4
0

You can easily get it by attr method:

var name = $("#id").attr("name");
Shahnewaz
  • 360
  • 4
  • 12
  • i'm using this in a php file with curl so i need to make it happen inside the same file my only hope is dom – Timo Jan 06 '19 at 03:12