Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

an easy one string array

Posted on 2009-07-08
2
Medium Priority
?
286 Views
Last Modified: 2012-05-07
why this script is returning me undefined ?

thsi script is generated by a server side code as seen the top and the script result on the page is under it...
Dim scr = "<script>"
        Dim i = 0
        scr += "var image1 = new Array();"
        scr += "var hidden = new Array();"
        scr += "var hidden2 = new Array();"
        scr += "var anchor = new Array();"
        For i = 0 To 9
            Dim image As New Image
            If i = 0 Or i = 5 Then
                Dim row As New TableRow
                row.Width = Unit.Percentage(100)
                Table1.Rows.Add(row)
                Dim row2 As New TableRow
                row.Width = Unit.Percentage(100)
                Table1.Rows.Add(row2)
            End If
            image.ImageUrl = "../images/addphoto.gif"
            image.ID = "images" & i
            image.Width = Unit.Pixel(60)
            image.Height = Unit.Pixel(60)
            Dim hidden1, hidden2 As New HiddenField
            hidden1.ID = "hidden1_" & i
            hidden2.ID = "hidden2_" & i
            Dim anchor As New HtmlAnchor
            anchor.HRef = "#"
            anchor.ID = "anch" & i
            anchor.InnerText = "Resmi Sil"
            anchor.Attributes.Add("onClick", "sil2('" & i & "');")
            anchor.Attributes.Add("style=visibility", "hidden")
            Dim cell As New TableCell
            cell.Controls.Add(image)
            cell.Controls.Add(hidden1)
            cell.Controls.Add(hidden2)
            Dim cell2 As New TableCell
            cell2.Controls.Add(anchor)
            If i < 5 Then
                Table1.Rows(0).Cells.Add(cell)
                Table1.Rows(1).Cells.Add(cell2)
            Else
                Table1.Rows(2).Cells.Add(cell)
                Table1.Rows(3).Cells.Add(cell2)
            End If
            scr += "image1[" & i & "] = '" & image.ClientID & "';"
            scr += "hidden1[" & i & "] = '" & hidden1.ClientID & "';"
            scr += "hidden2[" & i & "] = '" & hidden2.ClientID & "';"
            scr += "anchor[" & i & "] = '" & anchor.ClientID & "';"
        Next
        scr += "</script>"
        Dim scr2 = "<script>"
        scr2 += "function sil2(deger) {"
        'scr2 += "        var adres = image1[deger];"
        'scr2 += "        document.getElementById(anchor[deger]).style.visibility = 'hidden';"
        'scr2 += "        document.getElementById(hidden1[deger]).value = '';"
        'scr2 += "        document.getElementById(adres).src = '../images/addPhoto.gif';"
        scr2 += "   alert(HiddenField1a);  }</script>"
        Response.Write(scr)
        Response.Write(scr2)
 
 
 
AND THE SCRIPT IS  :
 
 
<script>
var image1 = new Array();
var hidden = new Array();
var hidden2 = new Array();
var anchor = new Array();
image1[0] = 'ctl00_ContentPlaceHolder1_images0';
hidden1[0] = 'ctl00_ContentPlaceHolder1_hidden1_0';
hidden2[0] = 'ctl00_ContentPlaceHolder1_hidden2_0';
anchor[0] = 'ctl00_ContentPlaceHolder1_anch0';
image1[1] = 'ctl00_ContentPlaceHolder1_images1';
hidden1[1] = 'ctl00_ContentPlaceHolder1_hidden1_1';
hidden2[1] = 'ctl00_ContentPlaceHolder1_hidden2_1';
anchor[1] = 'ctl00_ContentPlaceHolder1_anch1';
image1[2] = 'ctl00_ContentPlaceHolder1_images2';
hidden1[2] = 'ctl00_ContentPlaceHolder1_hidden1_2';
hidden2[2] = 'ctl00_ContentPlaceHolder1_hidden2_2';
anchor[2] = 'ctl00_ContentPlaceHolder1_anch2';
image1[3] = 'ctl00_ContentPlaceHolder1_images3';
hidden1[3] = 'ctl00_ContentPlaceHolder1_hidden1_3';
hidden2[3] = 'ctl00_ContentPlaceHolder1_hidden2_3';
anchor[3] = 'ctl00_ContentPlaceHolder1_anch3';
image1[4] = 'ctl00_ContentPlaceHolder1_images4';
hidden1[4] = 'ctl00_ContentPlaceHolder1_hidden1_4';
hidden2[4] = 'ctl00_ContentPlaceHolder1_hidden2_4';
anchor[4] = 'ctl00_ContentPlaceHolder1_anch4';
image1[5] = 'ctl00_ContentPlaceHolder1_images5';
hidden1[5] = 'ctl00_ContentPlaceHolder1_hidden1_5';
hidden2[5] = 'ctl00_ContentPlaceHolder1_hidden2_5';
anchor[5] = 'ctl00_ContentPlaceHolder1_anch5';
image1[6] = 'ctl00_ContentPlaceHolder1_images6';
hidden1[6] = 'ctl00_ContentPlaceHolder1_hidden1_6';
hidden2[6] = 'ctl00_ContentPlaceHolder1_hidden2_6';
anchor[6] = 'ctl00_ContentPlaceHolder1_anch6';
image1[7] = 'ctl00_ContentPlaceHolder1_images7';
hidden1[7] = 'ctl00_ContentPlaceHolder1_hidden1_7';
hidden2[7] = 'ctl00_ContentPlaceHolder1_hidden2_7';
anchor[7] = 'ctl00_ContentPlaceHolder1_anch7';
image1[8] = 'ctl00_ContentPlaceHolder1_images8';
hidden1[8] = 'ctl00_ContentPlaceHolder1_hidden1_8';
hidden2[8] = 'ctl00_ContentPlaceHolder1_hidden2_8';
anchor[8] = 'ctl00_ContentPlaceHolder1_anch8';
image1[9] = 'ctl00_ContentPlaceHolder1_images9';
hidden1[9] = 'ctl00_ContentPlaceHolder1_hidden1_9';
hidden2[9] = 'ctl00_ContentPlaceHolder1_hidden2_9';
anchor[9] = 'ctl00_ContentPlaceHolder1_anch9';
</script>
 
<script>
function sil2(deger) 
{   
alert(hidden1[4]);  
}
</script>

Open in new window

0
Comment
Question by:CahitEy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Accepted Solution

by:
CahitEy earned 0 total points
ID: 24809727
The only problem is space between i see after 1 hour :)  :
var
 image1 
=
 
new
 
Array
();   -  >var image1=new Array();

Open in new window

0
 
LVL 58

Expert Comment

by:amit_g
ID: 24809777
var hidden = new Array();

while used is

hidden1[0] = 'ctl00_ContentPlaceHolder1_hidden1_0';

Changing

scr += "var hidden = new Array();"

to

scr += "var hidden1 = new Array();"

should take care of it.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

715 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