开发者

Can i have links to a form prepopulate fields without GET

I have a link to a contact form from a 'products' page. I will have a link to the form next to each product, and would like to have that product name be the default value of the cooresponding input on the form. I would usually just have the href="whatever?prod=prodname" but I would prefer not to mess with the url. 开发者_StackOverflow社区

Can I do this somehow with POST data? Do I have to use js/jquery?

I think I can put the whole page in a form, and make the links submit buttons which post to my form, but that seems somewhat convoluted. Any ideas would be greatly appreciated.


I'm not sure why you don't want to "mess with the url", but you can certainly do it with POST data just like you describe in the last paragraph. And I'm not sure why that seems "convoluted" to you. Another option would be to intercept the click on the link and store the product name in a cookie, but that's no more or less "convoluted" than the POST option.

I guess I don't know what kind of solution you're looking for that would be elegant enough for you, but I think we've expired the possibilities: GET, POST, or a cookie. I guess you could also use HTML5 data storage, but that's not going to work on a lot of browsers.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜