Y
yawnmoth
I'm trying to make a bookmarklet that'll tell you all the variables
associated with a particular form. XPath, unfortunately, doesn't
work. Never mind the fact that the elements that can constitute form
variables are varied (input, textarea, select, etc), there's also the
fact that on malformed HTML, it's simply not going to match. For
instance,
<div>
<form action="">
<input type="text" name="a" />
</div>
<div>
<input type="text" name="b" />
</div>
<div>
<input type="submit" />
</form>
</div>
<script>
var headings = document.evaluate('//form//input', document, null,
XPathResult.ANY_TYPE, null);
var thisHeading = headings.iterateNext();
alertText = "";
while (thisHeading) {
alertText += thisHeading.getAttribute("name") + "\n"
thisHeading = headings.iterateNext();
}
alert(alertText);
</script>
If you hit the submit button, you'll get, as GET parameters, both 'a'
and 'b'. This is true in both Internet Explorer and Firefox. In
contrast, with XPath (the above is for Firefox, specifically; not sure
how to do XPath in Internet Explorer), you get only 'a'.
Any ideas?
associated with a particular form. XPath, unfortunately, doesn't
work. Never mind the fact that the elements that can constitute form
variables are varied (input, textarea, select, etc), there's also the
fact that on malformed HTML, it's simply not going to match. For
instance,
<div>
<form action="">
<input type="text" name="a" />
</div>
<div>
<input type="text" name="b" />
</div>
<div>
<input type="submit" />
</form>
</div>
<script>
var headings = document.evaluate('//form//input', document, null,
XPathResult.ANY_TYPE, null);
var thisHeading = headings.iterateNext();
alertText = "";
while (thisHeading) {
alertText += thisHeading.getAttribute("name") + "\n"
thisHeading = headings.iterateNext();
}
alert(alertText);
</script>
If you hit the submit button, you'll get, as GET parameters, both 'a'
and 'b'. This is true in both Internet Explorer and Firefox. In
contrast, with XPath (the above is for Firefox, specifically; not sure
how to do XPath in Internet Explorer), you get only 'a'.
Any ideas?