473,396 Members | 1,914 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

getting all the input elements of a malformed form tag

I'm trying to get a list of all the input elements of a form tag and
am having some difficulty doing so. First, here's my XHTML:

<div>
<form action="">
<input type="text" name="a" />
</div>
<div>
<input type="text" name="b" />
</div>
<div>
<input type="submit" />
</form>
</div>

It isn't semantically correct XHTML but that doesn't stop web
developers from coding like that.

Anyway, in both Firefox and IE, if you visit a webpage containing the
above, and hit the Submit button, the resultant URL will have both a
and b defined via GET.

I'd like to be able to get a list of the same input parameters that
the browser does for a given form element. I had been using "//
form[1]//input" as an XPath query, but that doesn't work, here,
because not all of the inputs are children of the form element.
Indeed, if I use DOMDocument::saveHTML(), I get something more like
this:

<div>
<form action="">
<input type="text" name="a" />
</form>
</div>
<div>
<input type="text" name="b" />
</div>
<div>
<input type="submit" />
</div>

Any ideas?
Sep 3 '08 #1
5 2250
On Sep 3, 7:05 am, yawnmoth <terra1...@yahoo.comwrote:
I'm trying to get a list of all the input elements of a form tag and
am having some difficulty doing so. First, here's my XHTML:

<div>
<form action="">
<input type="text" name="a" />
</div>
<div>
<input type="text" name="b" />
</div>
<div>
<input type="submit" />
</form>
</div>

It isn't semantically correct XHTML but that doesn't stop web
developers from coding like that.

Anyway, in both Firefox and IE, if you visit a webpage containing the
above, and hit the Submit button, the resultant URL will have both a
and b defined via GET.

I'd like to be able to get a list of the same input parameters that
the browser does for a given form element. I had been using "//
form[1]//input" as an XPath query, but that doesn't work, here,
because not all of the inputs are children of the form element.
Indeed, if I use DOMDocument::saveHTML(), I get something more like
this:

<div>
<form action="">
<input type="text" name="a" />
</form>
</div>
<div>
<input type="text" name="b" />
</div>
<div>
<input type="submit" />
</div>

Any ideas?
I'm not sure what you're trying to achieve here I'm afraid, but I do
have one piece of advice for you. Fix your HTML. There is no reason
whatsoever for it not to be well formed, and it's only ever going to
cause you grief. If you didn't write teh HTML in question then have a
quiet polite word with whomever did.
Sep 3 '08 #2
On Sep 3, 7:05 am, yawnmoth <terra1...@yahoo.comwrote:
I'm trying to get a list of all the input elements of a form tag and
am having some difficulty doing so. First, here's my XHTML:

<div>
<form action="">
<input type="text" name="a" />
</div>
<div>
<input type="text" name="b" />
</div>
<div>
<input type="submit" />
</form>
</div>

It isn't semantically correct XHTML but that doesn't stop web
developers from coding like that.

Anyway, in both Firefox and IE, if you visit a webpage containing the
above, and hit the Submit button, the resultant URL will have both a
and b defined via GET.

I'd like to be able to get a list of the same input parameters that
the browser does for a given form element. I had been using "//
form[1]//input" as an XPath query, but that doesn't work, here,
because not all of the inputs are children of the form element.
Indeed, if I use DOMDocument::saveHTML(), I get something more like
this:

<div>
<form action="">
<input type="text" name="a" />
</form>
</div>
<div>
<input type="text" name="b" />
</div>
<div>
<input type="submit" />
</div>

Any ideas?
Oh, something else just occurred to me after I made that previous
post. Why not just use the contents of $_GET?
Sep 3 '08 #3
Message-ID:
<aa**********************************@w7g2000hsa.g ooglegroups.comfrom
yawnmoth contained the following:
>I'd like to be able to get a list of the same input parameters that
the browser does for a given form element. I had been using "//
form[1]//input" as an XPath query, but that doesn't work, here,
because not all of the inputs are children of the form element.
Indeed, if I use DOMDocument::saveHTML(), I get something more like
this:
Wrong froup methinks.
--
Geoff Berrow 0110001001101100010000000110
001101101011011001000110111101100111001011
100110001101101111001011100111010101101011
http://slipperyhill.co.uk - http://4theweb.co.uk
Sep 3 '08 #4
the variables are in the $_GET array.
Sep 3 '08 #5
On Sep 3, 3:10 am, Gordon <gordon.mc...@ntlworld.comwrote:
On Sep 3, 7:05 am,yawnmoth<terra1...@yahoo.comwrote:
I'm trying to get a list of all the input elements of a form tag and
am having some difficulty doing so. First, here's my XHTML:
<div>
<form action="">
<input type="text" name="a" />
</div>
<div>
<input type="text" name="b" />
</div>
<div>
<input type="submit" />
</form>
</div>
It isn't semantically correct XHTML but that doesn't stop web
developers from coding like that.
Anyway, in both Firefox and IE, if you visit a webpage containing the
above, and hit the Submit button, the resultant URL will have both a
and b defined via GET.
I'd like to be able to get a list of the same input parameters that
the browser does for a given form element. I had been using "//
form[1]//input" as an XPath query, but that doesn't work, here,
because not all of the inputs are children of the form element.
Indeed, if I use DOMDocument::saveHTML(), I get something more like
this:
<div>
<form action="">
<input type="text" name="a" />
</form>
</div>
<div>
<input type="text" name="b" />
</div>
<div>
<input type="submit" />
</div>
Any ideas?

Oh, something else just occurred to me after I made that previous
post. Why not just use the contents of $_GET?
I'm using cURL to grab the contents of the webpage and
DOMDocument::loadHTML() to parse the contents. Although I'd certainly
like to send a request via GET, it's getting all the variables that
I'd need to do so that's the hard part.
Sep 3 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Kai Grossjohann | last post by:
I would like to put a text input field (in the sense of <input type="text">) and an image next to each other, where I know the size in pixels of the image, and I know the total width in em. I...
6
by: Michael Hamm | last post by:
Hi, I'm trying to write a <form> whihc will retrieve a Web page on another server. I have (essentially) this: <form action="http://cgi.cs.indiana.edu/~oracle/digest.cgi"> <input...
18
by: lawrence | last post by:
If I'm pretty sure there is just one form on the page, can i do this? var myForm = document.forms; If I'm not sure about the form, is it safer to do this? if (document.forms) { var myForm =...
6
by: Dennis Allen | last post by:
Hi. I got a checkbox in a form. When the form is submitted, an email is generated. In the email text is the field name: on or off. The client doesn't want to see on or off, but yes or no. ...
3
by: Ed Jay | last post by:
When I run the below js, I get the error: "document.form1.elements.checked) is null or not an object" <script type="text/javascript"> function get_menu_value(menu_name) { var mValue = 0; ...
0
by: ruju00 | last post by:
I am getting an error in Login() method of the following class FtpConnection public class FtpConnection { public class FtpException : Exception { public FtpException(string message) :...
10
by: eggie5 | last post by:
Is it possible to get a file without using a form post? I want to get the data (bytes) of a file, text or binary, and just save it to a variable. Similar to the post body of a form that has a...
5
by: laredotornado | last post by:
Hi, I have a number of INPUTs on my page that look like <input id="form_items" name="form_items " size="15" type="text" value="..." /> How do I refer the last one of these on my page? ...
8
omerbutt
by: omerbutt | last post by:
hi there i have a form with multiple input (type/text ) fields and three inputs(type/file) fields i have to submit the form via ajax because i have multiple forms on this page ,you can say it is a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.