Forum Moderators: phranque

Message Too Old, No Replies

Auto Fill In Form from Link?

Auto Fill a form with a number

         

kindredtnc

10:17 pm on Jul 29, 2003 (gmt 0)

10+ Year Member



I have a pharmcacy as a client and they want a link on their site to go to another site for "Online Refills".

The site that my clients page links to for online refills has the following message with a form box

"To enter your pharmacy's Web site, type in the

Pharmacy ID #___________

from your Refill Rx ID Card and press Enter."

is there any script that i can apply to the link that would fill in that ID # automatically when the page opens in a new window?

thanks for any help.

MonkeeSage

4:40 pm on Jul 30, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



kindredtnc:

Not sure about IE, but in Netscape if the new window opens from the same domain (or you get permissions for the target domain), I think that window 'aliasing' will work.

Here is a simple example (again, not sure about IE, but you can give it a shot :) ).

Script:

function formFill(targObj, fillVal) {
targObj.value = fillVal;
}

HTML (in old [opener] window):

...
<a href="http://same.domain/PharmID.htm" onclick="var w=window.open(this.href,'PharmID','chrome'); formFill(w.document.getElementById('pharmID'), '1234567'); return false;">Test 1</a>
<a href="http://same.domain/PharmID.htm" onclick="var w=window.open(this.href,'PharmID','chrome'); formFill(w.document.getElementById('pharmID'), '7654321'); return false;">Test 2</a>
...

HTML (in new [target] window):

...
<label for="pharmID">Pharmacy #: </label><input type="text" id="pharmID" name="pharmID"/>
...

Hope that helps.

Jordan

kindredtnc

7:07 pm on Jul 30, 2003 (gmt 0)

10+ Year Member



thanks alot for the info,ill check with the site im linking to about adding that feature.

garann

9:53 pm on Jul 30, 2003 (gmt 0)

10+ Year Member



You'd have to talk to the online pharmacy, but you could also try to skip that page altogether by sending the pharmacy ID directly to the page - on the online pharmacy's site - that processes it.

In the page where the user clicks the link to the online pharmacy, have a hidden input field with the same name as the input field for the pharmacy ID on the online pharmacy's page. Use JavaScript to submit the form containing your hidden field to the page which is the action of the form on the online pharmacy's site. Again, it's probably wise to ask permission before doing this.

So if their code looks like this:


<form name="frmPharmID" method="POST" action="getPharmID.jsp">
<input type="text" name="txtPharmID">
</form>

Yours would look like this:


<form name="frmOrderPerscrip" method="POST"
action="http://www.onlinepharmacy.com/getPharmID.jsp">
<input type="hidden" name="txtPharmID" value="1234-th-5">
</form>
<a href="http://www.onlinepharmacy.com"
onclick="document.forms[0].submit();return false;">
Click here to order a perscription</a>

Hope that's sort of useful,
g.