Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Q1106 I have a table which is used to present the user with a list of things to do actions on, how can I press a button in the first column and on pressing that, send the user to a new URL and pass with it the contents of the row in the table?

irt.org | Knowledge Base | JavaScript | Table | Q1106 [ previous next ]

Q1106 I have a table which is used to present the user with a list of things to do actions on, how can I press a button in the first column and on pressing that, send the user to a new URL and pass with it the contents of the row in the table?

In Internet Explorer 4 you may get the innerText of a tag, but if you want this to be compatible, simply write the table with JavaScript (watch the quotes):

<script language="JavaScript">
Loc = 'http.//www.server.com/cgi-bin/somecgi.pl';

tRow = new Array();
tRow[0] = 'value1';
tRow[1] = 'value2';
tRow[2] = 'value3';
tRow[3] = 'value4';

text = '<form><table>';
for (i=0,n=tRows.length; i<n; i++) {
    text += '<tr>';
    text += '   <td>';
    text += '      <input type="button" value=" '+i+' " onClick="location =\''+ Loc + '?' + tRow[i] + '\';">';
    text += '   </td>';
    text += '   <td>'+tRow[i]+'</td>';
    text += '</tr>';
}
text += '<\/table><\/form>';

document.write(Text);
//--></script>

Feedback on 'Q1106 I have a table which is used to present the user with a list of things to do actions on, how can I press a button in the first column and on pressing that, send the user to a new URL and pass with it the contents of the row in the table?'


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 6th July 2009. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2009 irt.org, All Rights Reserved.