I am trying to pass the value one form to another. I am getting ") missing" but I am not getting where I am going wrong. Is this the correct way to call all the parameters?
Uncaught SyntaxError: missing ) after argument list
$("#div1").load("http://ppp.gkdsjfgk.com/wp-content/themes/thestory/compare-form-site.php?loanamt=" +
<?php echo $_POST['loanAmt']; ?>."&occupation=" +
<?php echo $_POST['occupation']; ?>."&rateType=" +
<?php echo $_POST['rateType']; ?>."&age=" +
<?php echo $_POST['age']; ?>."&city=" +
<?php echo $_POST['city']; ?> );
You're using the wrong concatenator just after each of your PHP brackets ?>.
The dot (the concatenator for PHP) should be replaced with +
(the JavaScript concatenator) like this ?> +
.
$("#div1").load(
"http://ppp.gkdsjfgk.com/wp-content/themes/thestory/compare-form-site.php?loanamt=" +
<?php echo $_POST['loanAmt']; ?> + "&occupation=" +
<?php echo $_POST['occupation']; ?> + "&rateType=" +
<?php echo $_POST['rateType']; ?> + "&age=" +
<?php echo $_POST['age']; ?> + "&city=" +
<?php echo $_POST['city']; ?>
);
you are mixing PHP and JavaScript concatenation. (.) is used in PHP and (+) is used in JavaScript
concatenation in PHP is like this:
$val = 'Your'.' '.'val';
concatenation in JavaScript is like this:
var val = 'Your'+' '+'val';
so your code should be like this:
$("#div1").load("http://ppp.gkdsjfgk.com/wp-content/themes/thestory/compare-form-site.php?loanamt="+<?php echo $_POST['loanAmt'];?>+"&occupation="+<?php echo $_POST['occupation']; ?>+"&rateType="+<?php echo $_POST['rateType']; ?>+"&age="+<?php echo $_POST['age']; ?>+"&city="+<?php echo $_POST['city']; ?> );
try this one, first make a variable so that it will be easier to modify if there's still wrong, just comment here what's the error after you try this code.
<script>
// set variable
var loadAmt = "<?php echo isset($_POST['loanAmt']) ? $_POST['loanAmt'] : ''; ?>";
var occupation = "<?php echo isset($_POST['occupation']) ? $_POST['occupation'] : ''; ?>";
var rateType = "<?php echo isset($_POST['rateType']) ? $_POST['rateType'] : ''; ?>";
var age = "<?php echo isset($_POST['age']) ? $_POST['age'] : ''; ?>";
var city = "<?php echo isset($_POST['city']) ? $_POST['city'] : ''; ?>";
// your load variable
var loadVar = "http://ppp.gkdsjfgk.com/wp-content/themes/thestory/compare-form-site.php?loanamt="+loadAmt+"&occupation="+occupation+"&rateType="+rateType+"&age="+age+"&city="+city;
// load to specified div
$('#div1').load(loadVar);
</script>