• ### Announcements

#### Archived

This topic is now archived and is closed to further replies.

# Autocompletion of Html Forms

## Recommended Posts

Is there any way to make like in php a script that would fill a form automatically? I had thought of maybe reading the contents of the html code (can be of course an php/asp generated page), then parse like the names of the variables and then pass em to the script referenced in the form action="script" method=post tag, but I guess that would be force brute or stupid. Is there any good way to accomplish this??

JavaScript

##### Share on other sites
Personally Im not interested at all in learning JavaScript (though I know Java well, so I guess I could learn as fast as hell), however, dya mean I can do it with it, but, in an easy way, like, if I take a crash course in that language I would be able to do it, or is it accomplished with some weird technique that Id probably will have to google for a long time.

##### Share on other sites
PHP is a server-side process that isn''t exposed to the client. If you are generating the HTML form via PHP, you might be able to find a way to fill out fields in the form (I have no specific information). JavaScript, OTOH, is integrated into the HTML DOM in virtually every browser, so it is trivial to alter the text property of any textual field, etc.

No, you don''t need to learn the actual language. You simply need to lookup some functions in a reference or refer to any of several sites with free scripts.

##### Share on other sites
K, thx a lot Oluseyi, Ill be googling for some time then

##### Share on other sites
It's trivial to have text boxes already filled out using PHP. For example,

<form action="<?=$_SERVER['PHP_SELF']?>" method="post"> <textarea><?=$text_to_put_in_textarea?></textarea>
<input type="text" value="<?=$stuff_to_put_in_text_box?>" /> <input type="submit" name="submit" value="<?=$button_text?>" />

But that's probably not what you're trying to do.

[edited by - teamonkey on March 20, 2004 7:37:11 AM]

##### Share on other sites
quote:
Original post by teamonkey
But that''s probably not what you''re trying to do.

Yup, Im trying to do something like a "bot" that would fill a given form in X server with A,B,C...N given fields (that of course it would know beforehand)

##### Share on other sites
Javascript''s the only way to go then.

You might find something useful in Pear''s HTML::Form and HTML::QuickForm classes. Link

##### Share on other sites
I have done some work in auto-completion and auto-update of HTML form fields. There is a paper available on how one can
program such a mechanism in Javascript. You can have a look at the paper here http://www.brics.dk/~sunil. Also have a look at the examples in the paper which can be found here http://www.brics.dk/~sunil/worldcupcon/ShowCase.html
There is also a compiler available that takes auto-completion specifications in a dialect of HTML and then interweaves with the form elements to generate the javascript code.

Getting back to your question, the idea is to model relationships among fields in a manner that ensures that the values can be deduced by this relationship alone. The question remains as to "when" and "how".

Lets take an example:
We have a form that contains three textual fields A,B,C with no default values ( for simplicity). Suppose the relationships
among the three fields is that A = B + C.
So, if I know A,B I can determine the value of C
similarly, if I know C,A I can determine the value of B
and also, given B,C I can determine tyhe value of A

This can be encoded as a kind of rule triggers based on what field values are known.
The "how" part can be encoded as function calls to a library.

Imagine what happens if I know all the three field values A,B and C. Well, I can almost certainly say either the three values
satisfy the relationship or not.......

I guess this is more advanced and complicated but I have given you the essential idea. Also, have a look at the examples. They are quite illustrative. Let me know if anything is unclear.

I hope that helps.
Sunil

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627652
• Total Posts
2978421

• 10
• 12
• 22
• 13
• 33