change from action URL on-the-fly
Posted: Tue Jan 20, 2009 10:25 am
Hey, I want to change a form action url based on user input, and I used hyperlink to submit a form (since I have lots of rows like this and each has different values passed to javascript select_claim() function.). But it doesn't work! I have very simple php code here, but the it is the javascript problem. Can anyone help? Thanks very much!
Code: Select all
<form action="" method="post" name="smForm" id="smForm">
<table>
<tr>
<td><a href="" onclick="select_claim('<?=$claimNumber?>', '<?=$suffix?>', '<?=$claimDiag1?>', '<?=$claimDiag2?>', '<?=$claimClass?>', '<?=$claimProvider?>'); return getclaim('myclaimForm'); " title="view claim detail"><?=$claimNumber?></a></td>
</tr></table>
<input type="hidden" name="claimNumber" id="claimNumber" value="<?=$claimNumber?>" />
<input type="hidden" name="suffix" id="suffix" value="<?=$selectedSuffix?>" />
<input type="hidden" name="claimDiag1" id="claimDiag1" value="<?=$claimDiag1?>" />
<input type="hidden" name="claimDiag2" id="claimDiag2" value="<?=$claimDiag2?>" />
<input type="hidden" name="claimClass" id="claimClass" value="<?=$claimClass?>" />
<input type="hidden" name="providerName" id="providerName" value="<?=$providerName?>" />
</form>
<script language="Javascript">
<!--
function select_claim(claimnumber, suffix, claimdiag1, claimdiag2, claimclass, providername)
{
getSection('claimNumber').value = claimnumber;
getSection('suffix').value = suffix;
getSection('claimDiag1').value = claimdiag1;
getSection('claimDiag2').value = claimdiag2;
getSection('claimClass').value = claimclass;
getSection('providerName').value = providername;
}
function getclaim(formName)
{
if(getSection('claimClass').value == 'M')
document.forms[formName].action = 'claimDetailMed.php';
else if(getSection('claimClass').value == 'D')
document.forms[formName].action = 'claimDetailDen.php';
else if(getSection('claimClass').value == 'V')
document.forms[formName].action = 'claimDetailVis.php';
else(getSection('claimClass').value == 'P')
document.forms[formName].action = 'claimDetailPha.php';
document.forms[formName].submit();
return true;
}
}
//-->
</script>