| asked by Fahdmurtaza on 03/04/2006 04:36PM PKT |
| This solution was worth 500 Points and received a grade of A |
Hi Experts
I have been trying to fix that, but I can’t , so need your help
I am writing a CRM application where I have to change the form submission on basis of a selection from a drop dwon list.
Here is the code
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd” target=”_blank” rel=”nofollow”>http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml” target=”_blank” rel=”nofollow”>http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />
<title>Untitled Document</title>
<SCRIPT language=”JavaScript”>
function Changeaction()
{
if(this.document.searchleads.status.options[this.selectedIndex].value =”")
{
this.document.searchleads.action =”index.php”;
}
else
if(document.searchleads.status.options[this.selectedIndex].value =”NEW “)
{
this.document.searchleads.action =”index.php”;
}
else
{
this.document.searchleads.action =”indexbystatus.php”;
}
return action;
}
</SCRIPT>
</head>
<body>
<form name=”searchleads” method=”post” onsubmit=”Changeaction()”>
<h5>Volcano Web /
<label>
<select onchange=”Changeaction()” name=”status” id=”status”>
<option value=”" >All</option>
<option value=”NEW” selected>NEW</option>
<option value=”FOLLOWUP REQUIRED” >FOLLOWUP REQUIRED</option>
<option value=”UNSERVICABLE LEAD” >UNSERVICABLE LEAD</option>
<option value=”DUPLICATE” >DUPLICATE</option>
<option value=”APPLICATION IN PROGRESS” >APPLICATION IN PROGRESS</option>
<option value=”LOAN SETTLED” >LOAN SETTLED</option>
<option value=”UNSUCCESSFUL APPLICATION” >UNSUCCESSFUL APPLICATION</option>
</select>
</label><input name=”" value=”Go” type=”submit” onclick=”Changeaction()” />
</h5>
</form>
</body>
</html>
What I want to do is that when “All” or “NEW” is slected from the drop down, the form action should be changed to index.php else it should be changed to indexbystatus.php.
Thankss for your help. I really need help in this.
Regards,
Fahd Murtaza
—————————————————————————————–
Accepted Answer from Roonaan
Date: 03/04/2006 04:40PM PKT
Grade: A
Accepted Answer
Change your select to:
And your script to:
function Changeaction(selBox)
{
var frm = selBox.value;
var sel = selBox.options[selBox.selectedIndex].value;
if(sel == “” || sel == “NEW”) {
frm.action = ‘index.php’;
} else {
frm.action = ‘indexbystatus.php’;
}
}
However, this does not solve the problem for people having disabled javascript…
-r-
Comment from Fahdmurtaza
Date: 03/04/2006 05:04PM PKT
My Comment
Thanks…and a small fix to above…now it works
The latest working thing I have is
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd” target=”_blank” rel=”nofollow”>http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml” target=”_blank” rel=”nofollow”>http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />
<title>Untitled Document</title>
<SCRIPT language=”JavaScript”>
function Changeaction(selBox)
{
// var frm = selBox.value;
var sel = selBox.options[selBox.selectedIndex].value;
if(sel == “” || sel == “NEW”) {
document.searchleads.action = ‘index.php’;
} else {
document.searchleads.action = ‘indexbystatus.php’;
}
}
</SCRIPT>
</head>
<body>
<form name=”searchleads” method=”post” onsubmit=”Changeaction(this.status)”>
<h5>Volcano Web /
<label>
<select onchange=”Changeaction(this)” name=”status” id=”status”>
<option value=”" >All</option>
<option value=”NEW” selected>NEW</option>
<option value=”FOLLOWUP REQUIRED” >FOLLOWUP REQUIRED</option>
<option value=”UNSERVICABLE LEAD” >UNSERVICABLE LEAD</option>
<option value=”DUPLICATE” >DUPLICATE</option>
<option value=”APPLICATION IN PROGRESS” >APPLICATION IN PROGRESS</option>
<option value=”LOAN SETTLED” >LOAN SETTLED</option>
<option value=”UNSUCCESSFUL APPLICATION” >UNSUCCESSFUL APPLICATION</option>
</select>
</label><input name=”" value=”Go” type=”submit” onclick=”Changeaction()” />
</h5>
</form>
</body>
</html>
Regards,
Fahd Murtaza
Fahd Murtaza