Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

error in calling and executing code

Status
Not open for further replies.

tc3596

Technical User
Joined
Mar 16, 2001
Messages
283
On clicking a button, I am trying to call a script that checks to see if form.YachTxt.Value is not empty. If true then redirect to another page. I keep getting syntax errors.

<form name=baco action="CSSDKPIScreenTest.asp">


<button class="BtnRefresh" value = "1" accesskey="R" id="Request" name="Request" onclick="javascript:Yacht()">
<u>R</u>-<%=Term.String(0, "Request")%>
</button>


Here is my function:

<script language="javasript">
function Yacht()

{
document.Form1.action = "EPRequestTypes.asp?Action=1&ItemCode=" + Baco.YachtTxt.Value + "&CustomerContactID=" + Baco.ContTxt.Value + "&Description=" + Baco.VoyageTxt.Value + "&CustomerID=" + Baco.AccountTxt.Value";
document.Form1.submit();
return true;
}

</script>

Any thoughts on this?
 
What do your syntax errors say? Right off the bat, I can see you're using "Baco" with a capital 'B' in your JavaScript, while it has a lower-case b (baco) in the FORM tag.

Dave

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...east is east and west is west and if you take cranberries and stew them like applesauce
they taste much more like prunes than rhubarb does
[infinity]
 
Replace this:

Code:
onclick="javascript:Yacht()"

with this:

Code:
onclick="Yacht();"

and this:

Code:
<script language="javasript">

with this:

Code:
<script type="text/javascript">

(there is no such language as "javasript")

Hope this helps,
Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
And your function is not testing the value of the field it is setting the action of the form. You said you wanted to check the value then redirect but you are neither testing or redirecting.


Stamp out, eliminate and abolish redundancy!
 
You'd want this as a replacement function:

Code:
function Yacht() {
	var frm1 = document.forms['Form1'];
	var frmB = document.forms['baco'].elements;
    frm1.action = "EPRequestTypes.asp?Action=1&ItemCode=" + frmB['YachtTxt'].value + "&CustomerContactID=" + frmB['ContTxt'].value + "&Description=" + frmB['VoyageTxt'].value + "&CustomerID=" + frmB['AccountTxt'].value;
    frm1.submit();    
    return true;
}

Your old one had too many quotes, and was using an uppercase "V" on value, which is incorrect.

Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top