如何通过点击<a> tag?

时间:2017-08-31 08:44:25

标签: javascript html jsf

i have a problem to passing js variable to a native (non-bootstrap) modal. here's my code:

<a class="big-blue-button" id="seminor-enroll">
                        <h:outputLabel value="入会申し込み"/>
                    </a>

                    <a class="big-orange-button" id="seminor-trial">
                        <h:outputLabel value="体験申し込み"/>
                    </a>

                    <script type="text/javascript">
                        $("a.big-blue-button").click(function(){
                            var id = $("a.big-blue-button").attr("id");
                            showModal(id);
                            document.getElementById('applyType').value = id;
                        });
                    </script>
                    <script type="text/javascript">
                        $("a.big-orange-button").click(function(){
                            var id = $("a.big-orange-button").attr("id");
                            showModal(id);
                            document.getElementById('applyType').value = id;
                        });
                    </script>

when i click <a class="big-blue-button" id="seminor-enroll"> i want that <a id="seminor-enroll"/> is save as value of <h:inputHidden> tag in modal form.

this is my modal code:

<div id="myModal" class="modal">

        <!-- Modal content -->
        <div class="modal-content ui-g-12 ui-lg-6 ui-md-8 ui-sm-10">

            <div class="ui-g" style="position: relative">
                <span class="close">&#x2573;</span>
                <div class="ui-g-12">
                    <div class="ui-g-12">

                        <div class="ui-g-12 ui-sm-12 user-form-panel ui-fluid">
                            <h:form>

                                <div class="ui-g-12" style="text-align:initial">
                                    //in this inputHidden i want get that <a> id value
                                    <h:inputHidden id="applyType" value="#{memberBean.applyType}" />
                                    <p:commandButton icon="ui-icon-person" value="ログイン" ajax="false" action="#{memberBean.login()}" style="float:left"/>
                                    <p:link styleClass="ui-button" outcome="/index.html" value="ホームに戻る" style="margin-left: 5%; float:left;border-radius:3px;line-height: 30px;"/>
                                </div>
                            </h:form>
                            <p class="or-text" style="text-align:center;">OR</p>
                        </div>


                    </div>
                </div>
            </div>
        </div>

    </div>

and final result i want that value (from <a id> to <h:inputHidden) show in jsf bean just like this:

public String login() {

    System.out.println(applyType);

    return "";
}

is this possible to do that?

0 个答案:

没有答案