开发者

Anchors in a dropdown menu

I开发者_StackOverflow中文版 have a page with several links. I want to make that when a user clicks link #1 he will be redirected to a contact form and select item #1 in the dropdown menu. Same goes for #2 and item #2 in the dropdown menu. Is this possible ?


You will have to pass a query string value through your links and use that value to pre-select an item from your selectbox, example:

<a href="mysite.com?var=test">Link One</a>

Now you can get the value of var=test query string and make a condition if it is set, you pre-select an option from the select dropdown based on that variable.


Yes, it is possible, but you will have to use Javascript for this:

<script type="text/javascript">
function SetItem(item)
{
    document.myForm.myDropDown[item].selected = true;
}
</script>
<a href="#form_anchor" onclick="SetItem(0)">Select 1st item</a>

Edit:

After reading sAc's answer, I'm not sure if you need the functionality to be available on the same page (in which case you can use the solution I proposed) or in a different page (in which case you should follow sAc's solution).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜