php - .val stops form from working -
i have this checkout page (you have add item) uses javascript / jquery seen in this jsfiddle show/hide fields separate shipping address. when showing, set value of fields ''
, when hiding set values of fields same respective fields in billing form.
when submit form should taken paypal login screen (try filling out form without toggling different shipping address , submitting) if toggle shipping address comes same page.
i have debugged enough know modifying fields .val()
breaking form. if comment out bits , manually toggle visibility dev tools, or if fill out billing form , never show/hide shipping (so .val()
never called), works fine.
if going @ page , give try, know successful if paypal screen, otherwise coming same page (the form's action same page, can't find processes data - full php page can found here - modified version of wpec's shopping cart page
here (most of) relevant javascript:
$('#reveal-shipping').click(function(){ if ( $('.wpsc_checkout_table.table-2').is(':animated') ) return; if( $('.wpsc_checkout_table.table-2').css('display') == 'none' ){ $('.wpsc_checkout_table.table-2').slidetoggle(); $('.wpsc_checkout_table.table-2').find('input, select, textarea').val(''); document.getelementbyid('reveal-shipping').innerhtml = 'ship billing address ←'; } else { ( i=0; < fields.length; i++ ){ thisval = $(fields[i][0]).val(); $(fields[i][1]).val( thisval ); } $('.wpsc_checkout_table.table-2').slidetoggle(); document.getelementbyid('reveal-shipping').innerhtml = 'ship different address →'; } });
you can find rest on the jsfiddle , on the page itself
thanks in advance i'm stuck on this!
i think problem using display: none hide "different shipping adress". when input field has display none, not sent formular. , because of redirects checkout page.
you use visibility: hidden, still take space.
but recommend not way, because if user has turned javascript off won't work. should send field , in php, check whether different adress fields have been submitted, , if have, use them.
edit: use position place them outside of window, like:
position:absolute; top: -9999px; visibility:hidden;