SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Zealot Goldilocks's Avatar
    Join Date
    Apr 2003
    Location
    Three Bear's Cottage
    Posts
    126
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Using javascript to access an ASP array

    I am creating an array by selecting records from a database using ASP/SQL and then using:

    <%
    Alldata = rs.Getrows()

    For int_Row = 0 To UBound(Alldata, 2)
    For int_Col = 0 To UBound(Alldata, 1)
    if txtCat1=Alldata(int_Col, int_Row) then
    response.write("Hello")
    End if
    Next
    Next
    %>

    txtCat1 is a textbox in an HTML form. Basically I am trying to check that a value being entered in here is valid by checking it against the values I am pulling out of the database.

    I need it to check the values when the submit button is pressed. I know I can create and call a Javascript function to check the value but how do I access the ASP array using Javascript?

    Hope I haven't confused you all!

  2. #2
    SitePoint Wizard bronze trophy
    Join Date
    Apr 2003
    Posts
    4,095
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can access a text box using JavaScript, but you cannot access any server-side language or framework from the client side. Since Microsoft ASP (as well as ASP.NET) is the latter, you cannot use JavaScript for this. Sorry.

  3. #3
    SitePoint Zealot Goldilocks's Avatar
    Join Date
    Apr 2003
    Location
    Three Bear's Cottage
    Posts
    126
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The reason I am asking is because I found this.

    http://www.15seconds.com/issue/000210.htm

    I am not asking for any server-side code to be executed onSubmit as I realise you can't do this without reloading the page. The array is created at the start of the code and assigned a variable name.

    I know you can write asp code within javascript code. All I want to do is get the value of the textbox using javascript and compare it to the values in the variable I previously defined at the start. I know this can be done, is anyone else able to help?

  4. #4
    SitePoint Wizard bronze trophy
    Join Date
    Apr 2003
    Posts
    4,095
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm a little confused here. I don't see how you can write ASP code in JavaScript. You can write JavaScript code within ASP code, but I don't think you can do it the other way around. Other than that, I'm stumped. Sorry.

  5. #5
    SitePoint Zealot Goldilocks's Avatar
    Join Date
    Apr 2003
    Location
    Three Bear's Cottage
    Posts
    126
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for replying anyway. Did you take a look at that link? Maybe, they're just talking rubbish, I don't know!

  6. #6
    SitePoint Wizard bronze trophy
    Join Date
    Apr 2003
    Posts
    4,095
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh! I get it now! I though they meant manipulating ASP data using JavaScript, but they mean feeding ASP data into a JavaScript block and then having JavaScript manipulate it dynamically. Sorry!

  7. #7
    SitePoint Zealot Goldilocks's Avatar
    Join Date
    Apr 2003
    Location
    Three Bear's Cottage
    Posts
    126
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yep, sorry I was having trouble explaining it!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •