jQuery pass clicked image src to fancybox popup form -
i have popup form activated upon clicking image, i've used fancybox have lightbox effect. 1 of form fields auto-filled clicked images src. have tried following no effect (nothing in console shopwing error):
jquery("#storefront li img").click(function() { var barimg = jquery(this).prop("src"); jquery("input[name=car]").val(barimg); });
html form:
<div style="display:none"> <form method="post" action="thanks.asp" id="modalbar"> <div class="formwrapper"> <label for="name">name <span class="red2">*</span></label> <input type="text" name="firstname"> </div> <div class="formwrapper"> <label for="car">car (please include <strong>make</strong> / <strong>model</strong> / <strong>year</strong>) <span class="red2">*</span></label> <input type="text" name="car"> </div> <div class="formwrapper"> <label for="reg">reg number</label> <input type="text" name="reg"> </div> <div class="formwrapper"> <label for="phone">telephone number</label> <input type="text" name="tel"> </div> <div class="formwrapper"> <label for="email">email address <span class="red2">*</span></label> <input type="text" name="emailfrom"> </div> <div class="formwrapper"> <label for="prefcontact">preferred contact method <span class="red2">*</span></label> <input type="text" name="conmeth"> </div> <div class="formwrapper"> <label for="maillist">join mailing list</label> <input type="checkbox" name="maillist" value="yes" checked="checked"> </div> <div class="field"> <input name="submit" type="submit" value="send form" class="contactsend" /> <input name="reset" type="reset" value="clear form" class="contactsend" /> </div> </form> </div>
basic fancybox:
jquery(".modaltowbartrigger").fancybox({ 'scrolling' : 'no', 'titleshow' : false });
any pointers appreciated?
try this~~ think missed '' in "";
jquery("#storefront li img").click(function() { var barimg = jquery(this).prop("src"); jquery("input[name='car']").val(barimg); });
or jquery('input[name="car"]') work too, jquery("input[name=car]") not select element,i think...
Comments
Post a Comment