set variable by calling function onClick

Trying to set a variable by calling a function onClick, please see code below, not sure how to display except by showing whole page.  The error is a syntax error in the function:

<!-- #include file="declareinc.asp"-->

<html>
<head>
<title>Work</title>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

     <%
SQLQueryAll = "SELECT * FROM tbl_work"
set rs_picsall=objconn.execute(SQLQueryAll)

SQLQuery = "SELECT * FROM tbl_work WHERE category ="'Audio 1'""
set rs_picsaudio1=objconn.execute(SQLQuery)
SQLQuery2 = "SELECT * FROM tbl_work WHERE category ="'Audio 2'""
set rs_picsaudio2=objconn.execute(SQLQuery2)
SQLQuery3 = "SELECT * FROM tbl_work WHERE category ="'Audio 3'""
set rs_picsaudio3=objconn.execute(SQLQuery3)



var setcategory=0
function changecategory1(){
setcategory = 1
alert(setcategory)
 
function changecategroy2(){
setcategory = 2
alert(setcategory)

function changecategory3(){
setcategory = 3
alert(setcategory)


%>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}//-->
</script>
</head>

<body>
<table width="110%" border="0" cellspacing="0" cellpadding="0">
 
   <tr bgcolor="#1D2F11">
    <td colspan="2" background="images/topfiller1.gif"><table width="1242" border="0" cellpadding="0" cellspacing="0" bgcolor="#DBD2BF">
      <tr>
        <td width="571"><img src="images/topgraphic.gif" alt="top graphic" width="571" height="91"></td>
        <td width="671" rowspan="5"><%

            if NOT rs_picsaudio1("image")<>"" then
       Response.write "There are no photos in this category."
        Else %>
          <img src="<%=rs_picsaudio1("image")%>" name="image_big" width="43"   border=0 id="image_big" /></td>
      </tr>
      <tr>
        <td style="margin-left:80px"><span class="style14">Works</span><br>
            <hr></td>
        </tr>
      <tr>
        <td>
          <table width="526" border="1" cellspacing="0" cellpadding="0">
            <tr>
              <td width="76"><a href="home.asp" title="home" target="_self" class="style15">HOME</a></td>
              <td width="142"><a href="biography.asp" title="biography" target="_self" class="style15">BIOGRPAHY</a></td>
              <td width="139"><a href="works.asp" title="works" target="_self" class="style15">WORKS</a></td>
              <td width="159"><a href="contactus.asp" title="contactus" target="_self" class="style15">CONTACT US</a></td>
            </tr>
          </table>            </td>
        </tr>
      <tr>
        <td>

              <span class="style16"><a href="" target="self" onClick="window.open(this.href);changecategory1()">AUDIO PAINTING I</a><br>
              <% if setcategroy="1" Then
Do While Not rs_picsaudio1.EOF %>
                <a href="web_photography_enlargement.asp?product=<%=rs_picsaudio1("ID")%>" target="blank"
   onClick="window.open(this.href);return false;" onMouseOver="MM_swapImage('image_big','','<%=rs_picsaudio1("image")%>',1);MM_setTextOfTextfield('txt_itemdescription','','<%=rs_picsaudio1("description")%>');MM_setTextOfTextfield('txt_itemdimensions','','<%=rs_picsaudio1("dimensions")%>');MM_setTextOfTextfield('txt_itemname','','<%=rs_picsaudio1("title")%>');MM_setTextOfTextfield('txt_itemprice','','<%=rs_picsaudio1("guideprice")%>'"><%=rs_picsaudio1("title")%>                </a> <br>
                <%rs_picsaudio1.MoveNext
Loop
              end if%>
                    <a href="" target="self" onClick="window.open(this.href);changecategory2()">AUDIO PAINTING II</a><br>
      
            <% if setcategroy="2" Then
Do While Not rs_picsaudio2.EOF %>
                <a href="web_photography_enlargement.asp?product=<%=rs_picsaudio2("ID")%>" target="blank"
   onClick="window.open(this.href);return false;" onMouseOver="MM_swapImage('image_big','','<%=rs_picsaudio2("image")%>',1);MM_setTextOfTextfield('txt_itemdescription','','<%=rs_picsaudio2("description")%>');MM_setTextOfTextfield('txt_itemdimensions','','<%=rs_picsaudio2("dimensions")%>');MM_setTextOfTextfield('txt_itemname','','<%=rs_picsaudio2("title")%>');MM_setTextOfTextfield('txt_itemprice','','<%=rs_picsaudio2("guideprice")%>'"><%=rs_picsaudio2("title")%>                </a> <br>
                <%rs_picsaudio2.MoveNext
Loop
              end if%>
                    <a href="" target="self" onClick="window.open(this.href);changecategory3()")">AUDIO PAINTING III</a><br>
              <% if setcategroy="3" Then
Do While Not rs_picsaudio3.EOF %>
                <a href="web_photography_enlargement.asp?product=<%=rs_picsaudio3("ID")%>" target="blank"
   onClick="window.open(this.href);return false;" onMouseOver="MM_swapImage('image_big','','<%=rs_picsaudio3("image")%>',1);MM_setTextOfTextfield('txt_itemdescription','','<%=rs_picsaudio3("description")%>');MM_setTextOfTextfield('txt_itemdimensions','','<%=rs_picsaudio3("dimensions")%>');MM_setTextOfTextfield('txt_itemname','','<%=rs_picsaudio3("title")%>');MM_setTextOfTextfield('txt_itemprice','','<%=rs_picsaudio3("guideprice")%>'"><%=rs_picsaudio3("title")%>                </a> <br>
                <%rs_picsaudio3.MoveNext
Loop
              end if%><%end if%>
                    </span></td>
        </tr>
      <tr>
        <td><input name="Input2" id="txt_itemname" class="gallerytitle" size="55" style="border:hidden; font-weight:bold; text-align:center; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px" value="<%=rs_picsaudio1("title")%>">
         
          <br><input name="Input3" id="txt_itemdimensions" class="gallerytitle" size="55" style="border:hidden; font-weight:bold; text-align:center; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px" value="<%=rs_picsaudio1("dimensions")%>">
          <br><input name="Input4" id="txt_guideprice" class="gallerytitle" size="55" style="border:hidden; font-weight:bold; text-align:center; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px" value="<%=rs_picsaudio1("guideprice")%>"><br>
              <textarea name="Input" class="gallerytitle" cols="85" rows="5" id="txt_itemdescription" style="border:hidden; font-weight:normal; text-align:center; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px"><%=rs_picsaudio1("description")%></textarea></td>
        </tr>
    </table></td>
  </tr>
  </table>
</body>
</html>
rabbits2Asked:
Who is Participating?
 
dosthConnect With a Mentor Commented:
you have the below function called inside VBScript

var setcategory=0
function changecategory1(){
setcategory = 1
alert(setcategory)
 
function changecategroy2(){
setcategory = 2
alert(setcategory)

function changecategory3(){
setcategory = 3
alert(setcategory)

it needs to be on the Javascript segment

i have attached the modified version pls check it

<!-- #include file="declareinc.asp"-->
 
<html>
<head>
<title>Work</title>
 
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
 
     <%
SQLQueryAll = "SELECT * FROM tbl_work"
set rs_picsall=objconn.execute(SQLQueryAll)
 
SQLQuery = "SELECT * FROM tbl_work WHERE category ="'Audio 1'""
set rs_picsaudio1=objconn.execute(SQLQuery)
SQLQuery2 = "SELECT * FROM tbl_work WHERE category ="'Audio 2'""
set rs_picsaudio2=objconn.execute(SQLQuery2)
SQLQuery3 = "SELECT * FROM tbl_work WHERE category ="'Audio 3'""
set rs_picsaudio3=objconn.execute(SQLQuery3)
 
%>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
 
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}//-->
 
 
var setcategory=0
function changecategory1(){
setcategory = 1
alert(setcategory)
 
function changecategroy2(){
setcategory = 2
alert(setcategory)
 
function changecategory3(){
setcategory = 3
alert(setcategory)
 
</script>
</head>
 
<body>
<table width="110%" border="0" cellspacing="0" cellpadding="0">
 
   <tr bgcolor="#1D2F11">
    <td colspan="2" background="images/topfiller1.gif"><table width="1242" border="0" cellpadding="0" cellspacing="0" bgcolor="#DBD2BF">
      <tr>
        <td width="571"><img src="images/topgraphic.gif" alt="top graphic" width="571" height="91"></td>
        <td width="671" rowspan="5"><%
 
            if NOT rs_picsaudio1("image")<>"" then
       Response.write "There are no photos in this category."
        Else %>
          <img src="<%=rs_picsaudio1("image")%>" name="image_big" width="43"   border=0 id="image_big" /></td>
      </tr>
      <tr>
        <td style="margin-left:80px"><span class="style14">Works</span><br>
            <hr></td>
        </tr>
      <tr>
        <td>
          <table width="526" border="1" cellspacing="0" cellpadding="0">
            <tr>
              <td width="76"><a href="home.asp" title="home" target="_self" class="style15">HOME</a></td>
              <td width="142"><a href="biography.asp" title="biography" target="_self" class="style15">BIOGRPAHY</a></td>
              <td width="139"><a href="works.asp" title="works" target="_self" class="style15">WORKS</a></td>
              <td width="159"><a href="contactus.asp" title="contactus" target="_self" class="style15">CONTACT US</a></td>
            </tr>
          </table>            </td>
        </tr>
      <tr>
        <td>
 
              <span class="style16"><a href="" target="self" onClick="window.open(this.href);changecategory1()">AUDIO PAINTING I</a><br>
              <% if setcategroy="1" Then
Do While Not rs_picsaudio1.EOF %>
                <a href="web_photography_enlargement.asp?product=<%=rs_picsaudio1("ID")%>" target="blank"
   onClick="window.open(this.href);return false;" onMouseOver="MM_swapImage('image_big','','<%=rs_picsaudio1("image")%>',1);MM_setTextOfTextfield('txt_itemdescription','','<%=rs_picsaudio1("description")%>');MM_setTextOfTextfield('txt_itemdimensions','','<%=rs_picsaudio1("dimensions")%>');MM_setTextOfTextfield('txt_itemname','','<%=rs_picsaudio1("title")%>');MM_setTextOfTextfield('txt_itemprice','','<%=rs_picsaudio1("guideprice")%>'"><%=rs_picsaudio1("title")%>                </a> <br>
                <%rs_picsaudio1.MoveNext
Loop
              end if%>
                    <a href="" target="self" onClick="window.open(this.href);changecategory2()">AUDIO PAINTING II</a><br>
      
            <% if setcategroy="2" Then
Do While Not rs_picsaudio2.EOF %>
                <a href="web_photography_enlargement.asp?product=<%=rs_picsaudio2("ID")%>" target="blank"
   onClick="window.open(this.href);return false;" onMouseOver="MM_swapImage('image_big','','<%=rs_picsaudio2("image")%>',1);MM_setTextOfTextfield('txt_itemdescription','','<%=rs_picsaudio2("description")%>');MM_setTextOfTextfield('txt_itemdimensions','','<%=rs_picsaudio2("dimensions")%>');MM_setTextOfTextfield('txt_itemname','','<%=rs_picsaudio2("title")%>');MM_setTextOfTextfield('txt_itemprice','','<%=rs_picsaudio2("guideprice")%>'"><%=rs_picsaudio2("title")%>                </a> <br>
                <%rs_picsaudio2.MoveNext
Loop
              end if%>
                    <a href="" target="self" onClick="window.open(this.href);changecategory3()")">AUDIO PAINTING III</a><br>
              <% if setcategroy="3" Then
Do While Not rs_picsaudio3.EOF %>
                <a href="web_photography_enlargement.asp?product=<%=rs_picsaudio3("ID")%>" target="blank"
   onClick="window.open(this.href);return false;" onMouseOver="MM_swapImage('image_big','','<%=rs_picsaudio3("image")%>',1);MM_setTextOfTextfield('txt_itemdescription','','<%=rs_picsaudio3("description")%>');MM_setTextOfTextfield('txt_itemdimensions','','<%=rs_picsaudio3("dimensions")%>');MM_setTextOfTextfield('txt_itemname','','<%=rs_picsaudio3("title")%>');MM_setTextOfTextfield('txt_itemprice','','<%=rs_picsaudio3("guideprice")%>'"><%=rs_picsaudio3("title")%>                </a> <br>
                <%rs_picsaudio3.MoveNext
Loop
              end if%><%end if%>
                    </span></td>
        </tr>
      <tr>
        <td><input name="Input2" id="txt_itemname" class="gallerytitle" size="55" style="border:hidden; font-weight:bold; text-align:center; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px" value="<%=rs_picsaudio1("title")%>">
         
          <br><input name="Input3" id="txt_itemdimensions" class="gallerytitle" size="55" style="border:hidden; font-weight:bold; text-align:center; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px" value="<%=rs_picsaudio1("dimensions")%>">
          <br><input name="Input4" id="txt_guideprice" class="gallerytitle" size="55" style="border:hidden; font-weight:bold; text-align:center; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px" value="<%=rs_picsaudio1("guideprice")%>"><br>
              <textarea name="Input" class="gallerytitle" cols="85" rows="5" id="txt_itemdescription" style="border:hidden; font-weight:normal; text-align:center; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px"><%=rs_picsaudio1("description")%></textarea></td>
        </tr>
    </table></td>
  </tr>
  </table>
</body>
</html>

Open in new window

0
All Courses

From novice to tech pro — start learning today.