How to display an alert box containing Html tags?
I want display the string containing HTML tags in an alert box . the onclick event triggers this action but the alert is not being displayed..
This is the javascript function for displaying the alert box..
function DisplayNext(Next){
alert(Next);
}
The Jsp is
String test="DisplayNext(\"<table><table cellspacing='10' cellpadding='10'><tr><th>ID</th><th>Lattitude </th><th>Longitude</th><th>Gpsid</th><th>Speed</th><th>Type</th><th>Routeid</th><th>Status</th><th>Passengers</th><th>Capacity</th><th>Delete</th><th>Update</th></tr><tr><td>1</td><td>20.0</td><td>51.0</td><td>19.0</td><td>30.0</td><td>Bus</td><td>3</td><td>Active</td><td>20</td><td>65</td><td><a href=Deletetable.jsp?command=deleteVehicles&vehicle_ID=1><img src='Delete.gif' alt='Delete' title='Delete' width='20' height='20'></a></td><td><a href=Home.jsp?command%3Dvehicle%26commandid%3Dupdate_form%26Vehicle_ID%3D1%26vehicle_locX%3D20.0%26vehicle_locY%3D51.0%26vehicle_Gpsid%3D19.0%26vehicle_speed%3D30.0%26vehicle_type%3DBus%26vehicle_routeid%3D3%26vehicle_status%3DActive%26vehicle_passengerno%3D20%26vehicle_capacity%3D65%26vehicle_agentid%3D3 ><img src='Update.gif' alt='Update' title='Update' width='20' height='20'></a></td></tr><table cellspacing='10' cellpadding='10'><tr><th>ID</th><th>Lattitude </th><th>Longitude</th><th>Gpsid</th><th>Speed</th><th>Type</th><th>Routeid</th><th>Status</th><th>Passengers</th><th>Capacity</th><th>Delete</th><th>Update</th></tr><tr><td>1</td><td>20.0</td><td>51.0</td><td>19.0</td><td>30.0</td><td>Bus</td><td>3</td><td>Active</td><td>20</td><td>65</td><td><a href=Deletetable.jsp?command=deleteVehicles&vehicle_ID=1><img src='Delete.gif' alt='Delete' title='Delete' width='20' height='20'></a></td><td><a href=Home.jsp?command%3Dvehicle%26commandid%3Dupdate_form%26Vehicle_ID%3D1%26vehicle_locX%3D20.0%26vehicle_locY%3D51.0%26vehicle_Gpsid%3D19.0%26vehicle_speed%3D30.0%26vehicle_type%3DBus%26vehicle_routeid%3D3%26vehicle_status%3DActive%26vehicle_passengerno%3D20%26vehicle_capacity%3D65%26vehicle_agentid%3D3 ><img src='Update.gif' alt='Update' title='Update' width='20' height='20'></a></td></tr><tr><td>2</td><td>-20.134946</td><td>57.527719</td><td>20.0</td><td>50.0</td><td>Bus</td><td>1</td><td>Active</td><td>45</td><td>65</td><td><a href=Deletetable.jsp?command=deleteVehicles&vehicle_ID=2><i开发者_C百科mg src='Delete.gif' alt='Delete' title='Delete' width='20' height='20'></a></td><td><a href=Home.jsp?command%3Dvehicle%26commandid%3Dupdate_form%26Vehicle_ID%3D2%26vehicle_locX%3D-20.134946%26vehicle_locY%3D57.527719%26vehicle_Gpsid%3D20.0%26vehicle_speed%3D50.0%26vehicle_type%3DBus%26vehicle_routeid%3D1%26vehicle_status%3DActive%26vehicle_passengerno%3D45%26vehicle_capacity%3D65%26vehicle_agentid%3D1 ><img src='Update.gif' alt='Update' title='Update' width='20' height='20'></a></td></tr></table>\")";
NextLink = "<br><a href='#' onclick="+test+"> Next</a>";
When the next link is pressed,no alert box is displayed.How do I display it?
I change my codes to something simpler still I am not able to display the html tags using alert box. The codes are in the comment of TheStijn
Your using double quotes both in your test string and you href tag. Do this instead:
String test = "DisplayNext('ID...')";
精彩评论