PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
potato_chip
Forum Newbie
Posts: 20 Joined: Mon Oct 06, 2008 10:38 am
Post
by potato_chip » 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>
Burrito
Spockulator
Posts: 4715 Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah
Post
by Burrito » Tue Jan 20, 2009 10:35 am
Code: Select all
fm = document.getElementById('smForm');
fm.action = "whatever";
potato_chip
Forum Newbie
Posts: 20 Joined: Mon Oct 06, 2008 10:38 am
Post
by potato_chip » Tue Jan 20, 2009 10:54 am
Burrito wrote: Code: Select all
fm = document.getElementById('smForm');
fm.action = "whatever";
could you please be more specific? Thank you very much!
Burrito
Spockulator
Posts: 4715 Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah
Post
by Burrito » Tue Jan 20, 2009 11:08 am
Code: Select all
<script>
function changeAction(where)
{
fm = document.getElementById("smForm");
fm.action = where;
fm.submit();
}
</script>
<select name="whatever" onChange="changeAction(this.value)">
<option value="http://www.google.com">google</option>
<option value="http://www.yahoo.com">yahoo</option>
<option value="http://www.msn.com">msn</option>
</select>
potato_chip
Forum Newbie
Posts: 20 Joined: Mon Oct 06, 2008 10:38 am
Post
by potato_chip » Tue Jan 20, 2009 12:22 pm
Acutually I'm using hyperlink to submit a form, not a submit button or dropdown list.
Burrito
Spockulator
Posts: 4715 Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah
Post
by Burrito » Tue Jan 20, 2009 12:23 pm
then call the function from the link
Code: Select all
<a href="javascript:void(0)" onClick="changeAction()">click me</a>