Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Passing Javascript Variables to ASP?

  • 08-07-2009 03:14PM
    #1
    Closed Accounts Posts: 408 ✭✭


    Hey again everyone,

    I got my last problem sorted, and now I'd like to ask a more generic question please...

    Basically I use javascript to set table rows that are selected by the user's mouse to the class "selected".

    From here I want to use ASP to pick out that particular record in my table for editing.

    I'm using an XML file and javascript to generate my html table. My thinking is that I could possibly set my variable of the row id to the value of the position of the record.

    I.e. rowId = 1, applicant.position = 1, and load up the xml record using selectSingleNode().

    Does this sound remotely viable? Any comments are MORE than welcome as I'm tearing my hair out here trying to get my head around this problem.

    Cheers,

    Dan


Comments

  • Registered Users, Registered Users 2 Posts: 21,278 ✭✭✭✭Eoin


    Can you change a hidden form field somewhere in that row with the JavaScript? Then it will be accessible to ASP through the Request.Form collection. Edit - or even just one hidden form field that's comma delimited or something.


  • Registered Users, Registered Users 2 Posts: 1,045 ✭✭✭Bluefrog


    Careful using comments as delimiters - could break if your data contains a comment - JSON is probably the most robust way of doing this kind of thing or failing that even something not commonly used like '|' would be an option.


  • Closed Accounts Posts: 408 ✭✭Chada


    I thought i'd come back to this thread to say thanks for the suggestions!

    I figured it out by passing the javascript variable through to asp by using a javascript variable link i.e.

    var srId = selectedRow.id;
    var url = applicants.asp?mode=updatedetail&selectedRowId='+srId+';

    Then request the variable as a string, and set it to the same position() as the applicant element using selectSingleNode.

    This will effectively compare the row id of the table with the position of the applicant element in the XML file.

    Hope this helps anyone else trying to figure out the same problem as me :)

    Dan


Advertisement