//Set the flags rmt2_flag_ask_lump_sum = false; rmt2_flag_ask_monthly_payment = false; form_element = false; if(document.getElementById('rmt2_calc_input')){ form_element = 'rmt2_calc_input'; }else if(document.getElementById('rmt_calc_input')){ form_element = 'rmt_calc_input'; } if(form_element != false){ number_of_inputs = document.getElementById(form_element).elements.length; for(x=0; x < number_of_inputs; x = x + 1) { el = document.getElementById(form_element).elements[x]; if(el.name == 'rmt2_flag_ask_lump_sum' && el.value == 'true') { rmt2_flag_ask_lump_sum = true; } if(el.name == 'rmt2_flag_ask_monthly_payment' && el.value == 'true') { rmt2_flag_ask_monthly_payment = true; } } } //Now create the form rmt_form_html_top = "
"; rmt_form_html_lump_sum = ""; rmt_form_html_monthly_payment = ""; rmt_form_html_bottom = "
Home value *
Existing mortgages
Property's zip code *
Youngest homeowner's age *
Desired lump sum payment
Desired monthly payments
"; document.write(rmt_form_html_top); if(rmt2_flag_ask_lump_sum) { document.write(rmt_form_html_lump_sum); } if(rmt2_flag_ask_monthly_payment) { document.write(rmt_form_html_monthly_payment); } document.write(rmt_form_html_bottom); // Check if input element exists if(form_element != false){ //Convert the FORM inputs from the USER into inputs that will be submitted to the API number_of_inputs = document.getElementById(form_element).elements.length; for(x=0; x < number_of_inputs; x = x + 1) { element_name = document.getElementById(form_element).elements[x].name; input_element_name = 'input_' + element_name; if(document.getElementById(input_element_name)){ document.getElementById(input_element_name).value = document.getElementById(form_element).elements[x].value; } else { alert(input_element_name); } } } function rmt2_calc_submit() { output_iframe = document.getElementById('rmt_calc_output_iframe'); output_div = document.getElementById('rmt_calc_output_div'); copyright_div = document.getElementById('rmt_calc_copyright'); // Check if element exists if(!output_iframe || !output_div || !copyright_div){ alert('Calculator error: rmt_calc_output_iframe, rmt_calc_output_div, or rmt_calc_copyright is missing.'); return false; } //Display the frame and make it the full width of it's containing DIV output_iframe.style.width = '100%'; output_div.style.display = 'block'; return true; }