View Full Version : Passing data in a string

Gary Williams
10-19-2007, 07:27 PM
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?



10-19-2007, 07:36 PM
Concatenate the value of x on, like so:

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

Gary Williams
10-19-2007, 08:38 PM
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