开发者

ID from tabs to form with javascript?

开发者 https://www.devze.com 2023-01-14 05:36 出处:网络
Ok, so Im totally new to javascript, but I would need to do following: on my page I have tabs (done with javascript) and then I have search form. Now I need from those tabs a id to put to that form.

Ok, so Im totally new to javascript, but I would need to do following:

on my page I have tabs (done with javascript) and then I have search form. Now I need from those tabs a id to put to that form.

I have tabs1 tabs2 tabs3 and all those href开发者_运维技巧="#1", href="#2" and so on. I would need to get that number out of that tab to form input value. So if use clicks Tab2, it would automatically put "2" as a value in one of my inputs of my form. How to do that? Thanks!


Explaination in HTML comments:

<!-- retrieves the value from href, skipping the first character -->
<a href="#1" onclick="document.forms.form_name.field_name.value=this.hash.substr(1)">Tab1</a>
<form name="form_name" action="" method="post">
<!-- defaults to tab 1 -->
<input type="hidden" name="field_name" value="1" />

</form>
0

精彩评论

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