Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Sep 2002
    Location
    South East UK. 35 miles east of London, in sight of the River Thames.
    Posts
    300
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Passing data in a string

    Hi All,

    In an asp application, I have a number of buttons hard coded as follows:

    <INPUT TYPE="BUTTON" NAME="Data1" VALUE="Data1" onClick="data('datasummarypopup.asp?formnumber=1');">
    <INPUT TYPE="BUTTON" NAME="Data2" VALUE="Data2" onClick="data('datasummarypopup.asp?formnumber=2');">
    <INPUT TYPE="BUTTON" NAME="Data3" VALUE="Data3" onClick="data('datasummarypopup.asp?formnumber=3');">

    This works fine but for the sake of tidy coding, I want to replace this list of buttons with a loop, ie,

    For x=1
    <% response.write "<INPUT TYPE='BUTTON' NAME='Data' VALUE='Data' onClick=""data('datasummarypopup.asp?formnumber=(x)');""><BR>" %>
    Next x

    This works in so far as it displays the popup but doesn't pass (parse?) the formnumber x so the data called from the database is not displayed. How do I get the 'x' into the string and be recognised?

    Regards

    Gary

  • #2
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    Concatenate the value of x on, like so:
    Code:
    <% response.write "<INPUT TYPE='BUTTON' NAME='Data' VALUE='Data' onClick=""data('datasummarypopup.asp?formnumber=" & x & "');""><BR>" %>
    Good luck

  • Users who have thanked Brandoe85 for this post:

    Gary Williams (10-19-2007)

  • #3
    Regular Coder
    Join Date
    Sep 2002
    Location
    South East UK. 35 miles east of London, in sight of the River Thames.
    Posts
    300
    Thanks
    10
    Thanked 0 Times in 0 Posts
    Hi Brandoe,

    Tried that before and it didn't work. That's because I messed up the sequence of (') and (").

    Your solution works a treat!!!!

    Many Thanks

    Gary


  •  

    Posting Permissions

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