user1127172
user1127172

Reputation: 11

Fetch the checkbox value in jquery when cloase image is clicked

I know this question is quite basic but I am new to JQuery and not able to workout the solution.

I want to fetch the checkbox value from a modal window when the cloase button i.e 'x' button which is an image is clicked.

Any help is appreciated. Thanks..

I added following code after $(document).ready(function(),

$('img#closeImg').on('click', function(){
alert($('.popupContact input[type=checkbox]').val());

Below is the html code

 <div id="popupScreen">
    <div id="popupContact">  
    <form name="ReportParametersForm" name="ProcessActionForm" action="<portlet:actionURL>
            <portlet:param name='generateReportAction' value='generateReportAction'/>
            </portlet:actionURL>" method="post" onSubmit="return sendUserFeedback(doNotAsk)"> 
        <img src="<%= renderRequest.getContextPath() %>/NavigationClose.gif" id="closeImg" align="right" onclick="disablePopup()">
        <br/> 
        <p id="contactArea">  
            To help us improve our intranet pages, can you please tell us in about 12 words, what you are accessing this area of the intranet for?  
            <br/><br/>

            <table>
            <tr> 
            <td><input type="text" name="userInput" id="userInput" size="60" onfocus="this.value='';" value="I am trying to find..."/></td>
            <td><input type="submit" name="submitFeedback" value="Send feedback"> </td>
            </tr>
            </table>
            <br/><input type="checkbox" name="doNotAsk" class=""> Please do not ask me for this feedback again
            </form>
    </div>
    <div id="thankYou">  
     <img src="<%= renderRequest.getContextPath() %>/NavigationClose.gif" align="right" onclick="disableNow()">
     <form name="closingForm" name="closingForm"> 
            <h5>Thank you for providing feedback to help us improve Exchange</h5>
            <br/>
            <br/>
            <input type="button" name="Close" value="Close" onClick="disableNow()">
            </form>
    </div>
    <div id="backgroundPopup"></div> 
    <div id="mask"></div> 
    </div>

Upvotes: 0

Views: 204

Answers (1)

Alex
Alex

Reputation: 35407

$('img#x').on('click', function(){
    alert($('.modal input[type=checkbox]').first().val());
});
  • Attaches an event to an image element with an id of x.
  • When clicked, the handler alerts the value of a checkbox inside a piece of HTML with a class named modal.

Upvotes: 1

Related Questions