|
|
|
|
![]() ![]() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members
Posts: 105 Joined: 16-April 05 From: Sala Bolognese Member No.: 5,757 |
Post
#1
May 22 2005, 08:18 AM
I'd like to know if there's a way to "autofill" form fields. On a web page (that I call A), i have a form with two text fields called F1 and F2. I want that clicking on a link on another page (B, for example) the page A will open and the field F1 will contain, for example, "choice 1". While clicking on another link in the same page ( I hope that you have understand my explanation. |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members
Posts: 1,161 Joined: 9-May 05 From: Brisbane, QLD Member No.: 6,818 |
Post
#2
May 22 2005, 08:50 AM
You can use $_SERVER['HTTP_REFERER'] to detect what page the user is on before arriving at the form then use an if else statement to print out a different value for each case e.g. CODE <input type="text" value="
<? php if ($something = $_SERVER['HTTP_REFERER']) { print "first message"; else print "second message"; } ?> "> |
![]() ![]() ![]() ![]() Group: Members
Posts: 69 Joined: 12-March 05 From: Australia Member No.: 4,401 |
Post
#3
May 25 2005, 03:09 PM
I'm sure ther would be a better way of doing this, but I have an answer for you using JavaScript. Your suggested 'Page B' would contain the following <script> tag, where "a.html" is the path to your suggested 'Page A'. CODE <script language="JavaScript1.2" type="text/javascript"> <!-- function NextPage(choice) { document.FormB.inputValue.value = choice; openWin = window.open("a.html", "Page_A", ""); } //--> </script> then, your 'links' on Page B would be buttons in a form, where the text you want entered on the next page is in the onClick event. eg. Input for Choice 1. HTML <form name="FormB"> <input type="hidden" name="inputValue" value=""> <p><input type="button" name="choice_1" value="This is 'Choice 1'" onClick="NextPage('Input for Choice 1')"> <p><input type="button" name="choice_2" value="This is 'Choice 2'" onClick="NextPage('Input for Choice 2')"> </form> Now over on 'Page A', place the following script, where F1 is the name of the input field (which is in the form named FormA, as shown below). CODE <script language="JavaScript1.2" type="text/javascript"> <!-- function fillField() { document.FormA.F1.value = window.opener.document.FormB.inputValue.value; } //--> </script> ... and then you will need to add an OnLoad event to the <body> tag of Page A to transfer the value HTML <body onLoad="fillField()"> <form name="FormA"> <p><input type="text" name="F1"> <p><input type="text" name="F2"> </form> </body> I hope this helps and solves the idea that you are trying to explain. |
![]() ![]() |
Similar Topics
| Topic Title | Replies | Topic Starter | Views | Last Action | |||
|---|---|---|---|---|---|---|---|
![]() |
8 | rob86 | 191 | 18th October 2009 - 01:52 AM Last post by: inverse_bloom |
|||
![]() |
39 | the blonde girl | 35,977 | 22nd August 2009 - 10:02 AM Last post by: ASHISHRANJAN |
|||
![]() |
1 | Ho-oh'sRealm | 24 | Yesterday, 03:27 PM Last post by: The Simpleton |
|||
![]() |
1 | groentjuh | 5,085 | 2nd August 2004 - 06:13 PM Last post by: OpaQue |
|||
![]() |
5 | The Simpleton | 423 | 31st August 2009 - 04:21 AM Last post by: Pankyy |
|||
![]() |
6 | LuciferStar | 11,417 | 7th November 2004 - 12:40 PM Last post by: eldeo |
|||
![]() |
4 | nutkitten | 1,809 | 11th October 2008 - 04:33 AM Last post by: sheepdog |
|||
![]() |
2 | ronelm2000 | 1,053 | 8th October 2007 - 10:29 AM Last post by: ronelm2000 |
|||
![]() |
1 | Vacant | 5,661 | 4th March 2009 - 08:13 PM Last post by: aloKNsh |
|||
![]() |
4 | kudmus | 1,134 | 6th January 2009 - 08:07 AM Last post by: kudmus |
|||
![]() |
13 | DataHead | 9,724 | 21st October 2004 - 11:40 PM Last post by: alapidus |
|||
![]() |
2 | Watermonkey | 173 | 28th August 2009 - 11:42 PM Last post by: minimcmonkey |
|||
![]() |
3 | Triple X | 9,574 | 18th December 2008 - 10:52 PM Last post by: minimcmonkey |
|||
![]() |
1 | clouds421 | 4,353 | 26th September 2004 - 11:40 AM Last post by: wassie |
|||
![]() |
7 | rowita | 8,372 | 27th August 2009 - 04:16 AM Last post by: jamjamnorman |
|||
|
Open Discussion | Time is now: 8th November 2009 - 09:40 AM |
Web Hosting Powered by ComputingHost.com.