?
Solved

Getting syntax error : trying to pass a variable in location.href

Posted on 2005-05-13
10
Medium Priority
?
411 Views
Last Modified: 2012-06-27
I am using ASP.Net. I am trying to pass to variables  tp the location.href. I am getting syntax error at
location.href='frmCreditLimit.aspx?CustID='& strCustID&(......

Please help!!
 
 Dim strmessage As String
            Dim strCustID As String
            strCustID = "C000029"
strSiteID='"R000010"
            strmessage = "Our records indicate that we have not received your weekly payment. Please send your weekly payment check. If payment has been sent please ignore this message."
            Dim strScript As String = "<script language=JavaScript>"
            strScript += "if(confirm('Please click OK to enter the approval code to change the credit limit. ')){ location.href='frmCreditLimit.aspx?CustID='& strCustID&(???? HOW DO I PASS THE SECOND PARAMETER SITEID ) ;}"
            strScript += "</script>"

            If (Not Page.IsStartupScriptRegistered("clientScript")) Then
                Page.RegisterStartupScript("clientScript", strScript)
            End If
        End If
0
Comment
Question by:wilkersons
  • 6
  • 4
10 Comments
 
LVL 25

Expert Comment

by:archrajan
ID: 13997751
see what u get in ur view source
and post that
0
 
LVL 25

Accepted Solution

by:
archrajan earned 2000 total points
ID: 13997781
try this:
location.href='frmCreditLimit.aspx?CustID='+& strCustID&+'SiteID='+& strSiteID&
0
 
LVL 25

Expert Comment

by:archrajan
ID: 13997789
typo
shud be

location.href='frmCreditLimit.aspx?CustID='+& strCustID&+'&&SiteID='+& strSiteID&
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:wilkersons
ID: 13997866
Still getting syntax error

 strScript += "if(confirm('Please click OK to enter the approval code to change the credit limit. ')){ location.href='frmCreditLimit.aspx?CustID='+& strCustID&+'&&SiteID='+& strSiteID& ;}"
0
 

Author Comment

by:wilkersons
ID: 13997873
View Source:



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
      <HEAD>
            <title>TJR Online: Enter Items</title>
            <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
            <meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
            <meta content="JavaScript" name="vs_defaultClientScript">
            <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
      </HEAD>
      <body MS_POSITIONING="GridLayout">
            <form name="Form1" method="post" action="frmSale.aspx?SiteID=R000010&amp;SaleType=Reorder&amp;CustID=C000013&amp;Term=14&amp;OrdNbr=0101352005121731&amp;Custname=Krautheim%20Jewelry%20Inc." id="Form1">
<input type="hidden" name="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" value="" />
<input type="hidden" name="__VIEWSTATE" value="dDwtNjE4Mzg1NzE3O3Q8O2w8aTwxPjs+O2w8dDw7bDxpPDE+O2k8OD47aTw5Pjs+O2w8dDxwPHA8bDxUZXh0Oz47bDxFbnRlciBTYWxlcyBTY3JlZW4gZm9yIFIwMDAwMTA7Pj47Pjs7Pjt0PDtsPGk8MT47aTwzPjtpPDc+O2k8MTE+O2k8MTM+O2k8MTc+O2k8MTk+Oz47bDx0PHA8cDxsPFRleHQ7PjtsPFNhbGUgVHlwZTogTmV3IFJlb3JkZXIgMDEwMTM1MjAwNTEyMTczMSBmb3IgQzAwMDAxMyBLcmF1dGhlaW0gSmV3ZWxyeSBJbmMuOz4+Oz47Oz47dDxwPHA8bDxUZXh0Oz47bDxUZXJtOiAxNCAgICAgICAgQ3JlZGl0IExpbWl0OiQ0LDAwMC4wMDs+Pjs+Ozs+O3Q8cDxwPGw8VGV4dDs+O2w8XGU7Pj47Pjs7Pjt0PHA8cDxsPFRleHQ7PjtsPFxlOz4+Oz47Oz47dDxAMDxwPHA8bDxQYWdlQ291bnQ7XyFJdGVtQ291bnQ7XyFEYXRhU291cmNlSXRlbUNvdW50O0RhdGFLZXlzOz47bDxpPDE+O2k8MD47aTwwPjtsPD47Pj47Pjs7Ozs7Ozs7Ozs+O2w8aTwwPjs+O2w8dDw7bDxpPDE+Oz47bDx0PDtsPGk8Mz47aTw0PjtpPDU+Oz47bDx0PHA8cDxsPFRleHQ7PjtsPDA7Pj47Pjs7Pjt0PHA8cDxsPFRleHQ7PjtsPCQwLjAwOz4+Oz47Oz47dDxwPHA8bDxUZXh0Oz47bDwkMC4wMDs+Pjs+Ozs+Oz4+Oz4+Oz4+O3Q8cDw7cDxsPG9uY2xpY2s7PjtsPHJldHVybiBjb25maXJtKCdBcmUgeW91IHN1cmUgeW91IHdhbnQgdG8gUG9zdCBEYXRhPycpXDs7Pj4+Ozs+O3Q8cDw7cDxsPG9uY2xpY2s7PjtsPHJldHVybiBjb25maXJtKCdBcmUgeW91IHN1cmUgeW91IHdhbnQgdG8gY2FuY2VsJylcOzs+Pj47Oz47Pj47dDxwPDtwPGw8VmFsdWU7PjtsPDA7Pj4+Ozs+Oz4+Oz4+Oz65kRy8en5DwcwbH7UBjJfwAxiZbA==" />

<script language="javascript">
<!--
      function __doPostBack(eventTarget, eventArgument) {
            var theform;
            if (window.navigator.appName.toLowerCase().indexOf("netscape") > -1) {
                  theform = document.forms["Form1"];
            }
            else {
                  theform = document.Form1;
            }
            theform.__EVENTTARGET.value = eventTarget.split("$").join(":");
            theform.__EVENTARGUMENT.value = eventArgument;
            theform.submit();
      }
// -->
</script>

                  <span id="LblReportCaption" style="color:DarkRed;font-family:Arial;font-size:Medium;font-weight:bold;height:24px;width:396px;Z-INDEX: 108; LEFT: 246px; POSITION: absolute; TOP: 65px">Enter Sales Screen for R000010</span><a id="lnkSignOff" href="javascript:__doPostBack('lnkSignOff','')" style="font-family:Arial;font-size:X-Small;height:16px;width:52px;Z-INDEX: 107; LEFT: 784px; POSITION: absolute; TOP: 40px">Sign Off</a><span id="lblRSMOnline" style="color:DarkRed;font-family:Arial;font-size:Large;font-weight:bold;height:24px;width:396px;Z-INDEX: 106; LEFT: 248px; POSITION: absolute; TOP: 24px">TJR Online</span><a id="lnkContactUs" href="javascript:__doPostBack('lnkContactUs','')" style="font-family:Arial;font-size:X-Small;height:16px;width:72px;Z-INDEX: 105; LEFT: 704px; POSITION: absolute; TOP: 40px">Contact Us</a><img id="imgLogo" src="images\WALogo.jpg" border="0" style="height:92px;width:220px;Z-INDEX: 101; LEFT: 16px; POSITION: absolute; TOP: 8px" />
                  <HR style="Z-INDEX: 102; LEFT: 12px; WIDTH: 99.95%; POSITION: absolute; TOP: 100px; HEIGHT: 1px"
                        width="99.95%" color="#663333" SIZE="1">
                  <HR style="Z-INDEX: 103; LEFT: 235px; WIDTH: 76.47%; POSITION: absolute; TOP: 59px; HEIGHT: 1px"
                        width="76.47%" color="#663333" SIZE="1">
                  <a id="lnkHome" href="javascript:__doPostBack('lnkHome','')" style="font-family:Arial;font-size:X-Small;height:16px;width:36px;Z-INDEX: 104; LEFT: 656px; POSITION: absolute; TOP: 40px">Home</a><div id="pnlSaletype" style="background-color:White;border-color:DarkRed;border-width:1px;border-style:Solid;height:419px;width:624px;Z-INDEX: 109; LEFT: 16px; POSITION: absolute; TOP: 152px">
      
                        <P style="FONT-SIZE: medium; COLOR: #720000; FONT-FAMILY: Arial">Please enter the
                              Items.</P>
                        <P style="FONT-WEIGHT: bold; FONT-SIZE: x-small; COLOR: #720000; FONT-FAMILY: Arial">
                              <span id="lblSaleType" style="color:DarkRed;font-family:Arial;font-size:X-Small;font-weight:bold;height:24px;width:624px;">Sale Type: New Reorder 0101352005121731 for C000013 Krautheim Jewelry Inc.</span></P>
                        <P style="FONT-WEIGHT: bold; FONT-SIZE: x-small; COLOR: #720000; FONT-FAMILY: Arial">
                              <span id="lblTerm" style="color:DarkRed;font-family:Arial;font-size:X-Small;font-weight:bold;height:24px;width:192px;">Term: 14        Credit Limit:$4,000.00</span></P>
                        <P style="FONT-WEIGHT: bold; FONT-SIZE: x-small; COLOR: #720000; FONT-FAMILY: Arial">
                              <span id="Label1" style="color:DarkRed;font-family:Arial;font-size:X-Small;font-weight:bold;height:24px;width:144px;">Please scan the Item</span>
                              <input name="txtItem" type="text" id="txtItem" tabindex="1" style="TEXT-TRANSFORM: uppercase" />
                              <input type="submit" name="cmdSale" value="Enter Sale" id="cmdSale" style="width:80px;" /></P>
                        <P style="FONT-WEIGHT: bold; FONT-SIZE: x-small; COLOR: #720000; FONT-FAMILY: Arial">
                              <span id="lblErrorMsg" style="color:Red;font-family:Arial;font-size:X-Small;font-weight:bold;height:24px;width:144px;"></span>
                              <table cellspacing="0" cellpadding="4" rules="all" bordercolor="DarkRed" border="1" id="grdItems" style="color:DarkRed;background-color:White;border-color:DarkRed;border-width:1px;border-style:None;font-family:Arial;font-size:XX-Small;height:88px;width:616px;border-collapse:collapse;">
            <tr align="Center" style="color:#FFFFCC;background-color:#990000;font-weight:bold;">
                  <td>Rownbr</td><td align="Center" style="width:20mm;">Item</td><td align="Center" style="width:100mm;">Description</td><td style="width:20mm;">Quantity</td><td>Jewelers Cost</td><td>Ext Cost</td><td>Delete</td>
            </tr><tr style="color:#330099;background-color:#FFFFCC;">
                  <td>Totals</td><td>&nbsp;</td><td>&nbsp;</td><td>0</td><td>$0.00</td><td>$0.00</td><td>&nbsp;</td>
            </tr>
      </table></P>
                        <P>
                              <input type="submit" name="cmdBack" value="< Back" id="cmdBack" style="height:40px;width:120px;" />
                              <input type="submit" name="cmdNext" value="Post and Print >" id="cmdNext" onclick="return confirm('Are you sure you want to Post Data?');" style="height:40px;width:120px;" />
                              <input type="submit" name="cmdCancel" value="Cancel" id="cmdCancel" onclick="return confirm('Are you sure you want to cancel');" style="height:40px;width:120px;" />
                              <input type="submit" name="cmdDone" value="Done" id="cmdDone" disabled="disabled" style="height:40px;width:120px;" /></P>
                  
</div><span id="lblVal" Value="0" style="height:16px;width:104px;Z-INDEX: 110; LEFT: 680px; POSITION: absolute; TOP: 152px"></span><script language=JavaScript>if(confirm('Please click OK to enter the approval code to change the credit limit. ')){ location.href='frmCreditLimit.aspx?CustID='+& strCustID&+'&&SiteID='+& strSiteID& ;}</script>

</form>
      </body>
</HTML>
<script language=JavaScript>document.forms(0).elements['txtItem'].focus();</script><script language=JavaScript>document.forms(0).elements['txtItem'].focus();</script>
0
 
LVL 25

Expert Comment

by:archrajan
ID: 13997903
Try
location.href='frmCreditLimit.aspx?CustID='+strCustID+'&&SiteID='+strSiteID ;
0
 

Author Comment

by:wilkersons
ID: 13997979
No still getting synatx error.

I tried
strScript += "if(confirm('Please click OK to enter the approval code to change the credit limit. ')){ location.href='frmCreditLimit.aspx?CustID=C000029&SiteID=R000010';}"
this works fine so that means we are missing something while passing the variable..

I tried
strScript += "if(confirm('Please click OK to enter the approval code to change the credit limit. ')){ location.href='frmCreditLimit.aspx?CustID='+strCustID;}"

This does give me a message box but then I get the error "strCustID is not defined"

Thanks for ur help so far!
0
 
LVL 25

Expert Comment

by:archrajan
ID: 13998030
if strCustID is a asp variable?

try this

strScript += "if(confirm('Please click OK to enter the approval code to change the credit limit. ')){ location.href='frmCreditLimit.aspx?CustID='+<%= strCustID%>;}"
0
 

Author Comment

by:wilkersons
ID: 13998560
Guess what!!  its working .
I tried
strScript += "if(confirm('Please click OK to enter the approval code to change the credit limit. ')){ location.href='frmCreditLimit.aspx?CustID='+""" & strCustID & """+'&SiteID='+ """ & strSiteID & """ ;}"

Thanks for guiding me in the right direction.
0
 
LVL 25

Expert Comment

by:archrajan
ID: 13998582
Oh cool!
thanks for the points and the grade
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question