PDA

View Full Version : Link that when clicked, takes user to form and AUTO inputs the order id?



jarmanje
November 21st, 2007, 12:15 AM
Hello,

I have an html form (Order ID, Name, Message).

How can i send a link to someone, so that when they click it, it takes the user to my form webpage, then automatically inputs their order ID into the form?

I'm not sure what coding i would need or even where to look for this. So any advice is much appreciated!

Thanks a lot in advance

J

borrob
November 21st, 2007, 05:30 AM
are you using php?

jarmanje
November 21st, 2007, 08:48 AM
not yet... i just have the interface for my form.

borrob
November 21st, 2007, 10:31 AM
just for fun you can do this with javascript:


window.onload = function()
{
var str = location.href;
var pos = str.indexOf( '?' );
var variable_str = str.substring( pos + 1, str.length );
// now you can assign variable_str to your form orderid
}

put this code in the html that you want to get the order id.

now call the html through a link and ad ?orderid at the end....

RabBell
November 21st, 2007, 11:29 AM
BUT....this is something you should be doing using a Server Side language, such as PHP (as mentioned earlier) or ASP

I'm gonna talk about ASP but not because I'm recommending it over PHP but because I know it and I don't know PHP.

If you have a list of links (say for instance a page of products) then that information is likely to be pulled from a database. The sort of information being displayed could be something like cost, description, image and id. Each product would have a link (maybe on the image, title or just a bit of text saying "More details") and the link would be constructed server side with to produce a link like this.

http://myproducts/productdetails.asp?productid=5005

This way when the product details page recieves the key, 5005, it knows which product to display cause it uses the ID to lookup the DB and display it's details on the screen.

borrob
November 22nd, 2007, 02:22 AM
yes this really should be done by some server side script. But the javascript works ( just for fun ) if you want to....

jarmanje
November 22nd, 2007, 09:00 AM
Ok it seems it will be more complicated than i thought. Am checking out the php and asp ways

with the java, how do i pass a url to it?