/    Sign up×
Community /Pin to ProfileBookmark

Autofill a form onclick of a button (fill the form)

Hi to all the webmasters…..

My question is : I want to fill a form when someone clicks on the single button something like fill the form…

The basic structure is… user logins and then at the start up he has been asked to fill a basic form and whatever the details he enters will be stored in session…

I want these details to be filled up in “n” number of forms one by one on the click of a button..?

I think this makes some sense and I trust this will be possible to implement using PHP or Javascript or Ajax…

I need some suggestions on how to implement this…

Any help is greatly appreciated….

Many thanks in advance…

to post a comment
PHP

10 Comments(s)

Copy linkTweet thisAlerts:
@tirnaJun 17.2010 — I assume all the information that will be used to auto-fill the forms is stored in a database somewhere. If so, then you should be able to extract that information from the db when the user clicks a button and assign the information to the appropriate boxes in the forms.

The auto-filling can be done with or without AJAX.

If the information is not stored anywhere, then I'm not sure how you can 'guess' the required information to auto-fill the forms unless I am misunderstanding something.
Copy linkTweet thisAlerts:
@Shanu_chaudharyauthorJun 17.2010 — Tirna, Thanks for your reply.

If the information is not stored anywhere, then I'm not sure how you can 'guess' the required information to auto-fill the forms unless I am misunderstanding something. [/QUOTE]

The information is not stored in database. But let it be the results from database or wherever...... I will explain you the scenario I need..

I am having a list of links in right frame. If i click the link particular form opens in the left frame (each form contains different fields so I cant fill it with particular data..? ).

Now there is a button at the top of the main page say "fill form", then the auto fill needs to be worked for the fields with appropriate values in the left frame once the button is clicked.

Is this something possible to do??? ? Any kind of help / suggestions is welcome...

[B]NOTE:[/B] I am just trying to do this with the static values for 1 field (not from data base or using sessions) - testing...?

Thanks in advance
Copy linkTweet thisAlerts:
@tirnaJun 17.2010 — ok, I understand the concept of what you are trying to do but I still find this bit confusing.

I am just trying to do this with the static values[/QUOTE]

If these values are not stored initially in a database or flat file or whatever, then where do they come from? Are they stored in javascript or php variables? If so, how are these variables initialised?

The reason I ask is, unless these values are initally stored "somewhere" and then extracted from that storage to auto-fill the forms, I don't see how you obtain the information to auto-fill the forms.

If the form information is stored somewhere then you could use the appropriate functions for that storage medium to extract the info and populate the forms.

I think either I am missing something ? or what you want to do is not possible.
Copy linkTweet thisAlerts:
@Shanu_chaudharyauthorJun 17.2010 — [B]AS I told you "NOTE: I am just trying to do this with the static values for 1 field (not from data base or using sessions) - testing."[/B]

I am just trying this for testing purpose with static values

If u see my 1st post I mentioned there [B] user logins and then at the start up he has been asked to fill a basic form and whatever the details he enters will be stored in session... [/B]

So the values comes from sessions from the form user fills at the start up.... and using those values user can fill the form inside a frame with the click of a button.

(Button - fill form)

LEFT FRAME RIGHT FRAME

1st form 1st link

2nd form 2nd link

------- -------

------- -------

------- -------

and so on...

Hope this makes you understand what I need....
Copy linkTweet thisAlerts:
@tirnaJun 17.2010 — aaahh ok I see now ? the data will be stored in session variables. It wasn't clear to me what you meant back in your first post.

ok, all you have to do is assign appropriate session variable names to tie them in to a particular form and when the user loads a particular form, simply write the values of the session variables for that form to the appropriate boxes in the form.
Copy linkTweet thisAlerts:
@Shanu_chaudharyauthorJun 17.2010 — Yes...? but there are "n" no of forms to be filled up - suppose.. Not the particular form in an iframe to be filled .. here the scene is data needs to be filled in particular boxes with particular session variables by clicking a button "fill form" which is outside the iframe..

Is this possible??
Copy linkTweet thisAlerts:
@tirnaJun 17.2010 — 

Is this possible??[/quote]


yes it is. just give the session variables an appropriate name for the form they belong to and then simply write the value of the session variables to the appropriate box in their form whenever you need to using php.
Copy linkTweet thisAlerts:
@Shanu_chaudharyauthorJun 17.2010 — Yes... but how can I get to change the value of particular field inside a frame on click of a button which is outside the frame ?

If it is in the same form I can use something like "document.getElementById('fname').value = ""something"
Copy linkTweet thisAlerts:
@tirnaJun 17.2010 — yes, and that "something" would be the value of the session variable for the box with an id="fname". You would use php code to write the value of "something"

If you need help with the actual code, maybe post the code you have so far and I or someone else can try to help.
Copy linkTweet thisAlerts:
@Shanu_chaudharyauthorJun 17.2010 — Yes.. something will be the session variable. but how can i change the value inside an iframe using [B]document.getElementById('fname').value[/B]
×

Success!

Help @Shanu_chaudhary spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...