OM2
07-05-2012, 02:32 AM
I'm having trouble accessing a form element
I need to have a hidden field the value of which I need to pass through
I've seen lots of sample code, but just can't get it to work for what I need
I have some code that I adapted
I have:
var $contactform = $(this).closest('.contact-form-shop');
A few lines down I have:
var customername = $contactform.find('input[name="customername"]').val();
var email = $contactform.find('input[name="email"]').val();
var extradetails = $contactform.find('textarea[name="extradetails"]').val();
The above work fine!
I've added the following field:
<input type="hidden" name="shopName" value="XyZ" style="display: none;">
And I've tried things like:
var shopName = $contactform.find('shopName').val();
Console.log says the variable is undefined
Where am I going wrong?
Thanks
OM
I need to have a hidden field the value of which I need to pass through
I've seen lots of sample code, but just can't get it to work for what I need
I have some code that I adapted
I have:
var $contactform = $(this).closest('.contact-form-shop');
A few lines down I have:
var customername = $contactform.find('input[name="customername"]').val();
var email = $contactform.find('input[name="email"]').val();
var extradetails = $contactform.find('textarea[name="extradetails"]').val();
The above work fine!
I've added the following field:
<input type="hidden" name="shopName" value="XyZ" style="display: none;">
And I've tried things like:
var shopName = $contactform.find('shopName').val();
Console.log says the variable is undefined
Where am I going wrong?
Thanks
OM