I want to pull the answer to a radio button question & match it to fields in an API post. Currently it’s posting the wrong answers as I haven’t indicated which option it should be fetching from the radio button… Well that is what I have figured anyway.
What should I be adding so it selects the correct answer from each of the 3 radio buttons?
import { local } from ‘wix-storage’ ;
$w . onReady ( function (){
});
import { fetch } from ‘wix-fetch’ ;
export function submit_click ( event ) {
let crmApiURL = ‘https://www.nationaldebtassistance.org.uk/portal/ukdebtaid_api.php?user_id=UKDE0059&user_token=UKDEB0D4E&user_pass=11111111’
let apiend = ‘&c_emp_status=NIL&industries=NIL&ref_page=ukdebtaid.co.uk&my_ip=111111111’ ;
let apiQuery = ‘’ ;
if ( $w ( “#fname” ). value !== null && $w ( “#fname” ). value . length > 0 ) { apiQuery += ‘&name=’ + $w ( “#fname” ). value + ‘%20’ + $w ( “#lname” ). value + ‘’ ;}
//if ($w(“#lname”).value !== null && $w(“#lname”).value.length > 0) {crmApiURL += ‘&name=[’+$w(“#fname”).value+‘]’;}
if ( $w ( “#phone” ). value !== null && $w ( “#phone” ). value . length > 0 ) { apiQuery += ‘&phone=’ + $w ( “#phone” ). value + ‘’ ;}
if ( $w ( “#email” ). value !== null && $w ( “#email” ). value . length > 0 ) { apiQuery += ‘&email=’ + $w ( “#email” ). value + ‘’ ;}
if ( $w ( “#radioGroup1” ). value !== null && $w ( “#radioGroup1” ). value . length > 0 ) { apiQuery += ‘&debts=’ + $w ( “#radioGroup1” ). value + ‘’ ;}
if ( $w ( “#radioGroup2” ). value !== null && $w ( “#radioGroup2” ). value . length > 0 ) { apiQuery += ‘&emp_status=’ + $w ( “#radioGroup2” ). value + ‘’ ;}
if ( $w ( “#radioGroup3” ). value !== null && $w ( “#radioGroup3” ). value . length > 0 ) { apiQuery += ‘&country=’ + $w ( “#radioGroup3” ). value + ‘’ ;}
let fullurl = ‘https://www.nationaldebtassistance.org.uk/portal/ukdebtaid_api.php?user_id=UKDE0059&user_token=UKDEB0D4E&user_pass=1111111’ + apiQuery + ‘&c_emp_status=NIL&industries=NIL&ref_page=ukdebtaid.co.uk&my_ip=1111111’ ;
fetch ( fullurl , { method : ‘post’ })
// Check the result and manage errors - check the documentation for wix-fetch out
. then (( fetchResult ) => {
//Check to make sure the request was successful
})
. catch (( error ) => {
console . log ( error );
});}