Click here to Skip to main content
15,892,809 members
Home / Discussions / JavaScript
   

JavaScript

 
GeneralRe: Display Large Image in Small Space Pin
ASPnoob15-Oct-11 20:29
ASPnoob15-Oct-11 20:29 
QuestionRead from excel and download new file using javascript Pin
Member 769859611-Oct-11 18:24
Member 769859611-Oct-11 18:24 
AnswerRe: Read from excel and download new file using javascript Pin
Dennis E White11-Oct-11 19:58
professionalDennis E White11-Oct-11 19:58 
GeneralRe: Read from excel and download new file using javascript Pin
Member 769859612-Oct-11 0:35
Member 769859612-Oct-11 0:35 
GeneralRe: Read from excel and download new file using javascript Pin
Dennis E White12-Oct-11 8:02
professionalDennis E White12-Oct-11 8:02 
GeneralRe: Read from excel and download new file using javascript Pin
Member 769859612-Oct-11 19:42
Member 769859612-Oct-11 19:42 
AnswerRe: Read from excel and download new file using javascript Pin
Member 769429911-Oct-11 20:27
Member 769429911-Oct-11 20:27 
QuestionHow do I get the value of a drop down list into a javascript based table? Pin
shabbarank511-Oct-11 0:46
shabbarank511-Oct-11 0:46 
Hi all...

Im trying to move selected items from various drop down lists into a javascript based table. Below is an example of the code I currently have. So I select an item from a list:

PHP
<select name="Activity">
<?php
$sql = "SELECT Status FROM Activity";
$rs = mysql_query($sql) or trigger_error(mysql_error() . " unable to run query.");
echo "<option></option>";
while($row = mysql_fetch_assoc($rs))
{
  echo "<option value=\"".$row['Activity']."\">".$row['Status']."</option>\n  ";
}
?>
</select>


and then I want to move the selected item into its relevant field location within a table as per:

JavaScript
<button onclick='addRow();'>Add to Table</button>
<script type='text/javascript'>
	function addRow(){
		//get a reference to the table tbody
		var myTable = document.getElementById('myTable').getElementsByTagName('TBODY')[0];
		//create the table row
		var tr = document.createElement('TR');
		//create the 4 column cells
		var td1 = document.createElement('TD');
		 	td1.innerHTML = '<input class="name" />';
		var td2 = document.createElement('TD');
			td2.innerHTML = '<input class="date" />';
		var td3 = document.createElement('TD');
			td3.innerHTML = '<input class="name" />';
		var td4 = document.createElement('TD');
			td4.innerHTML = '<input class="hours" />';
		var td5 = document.createElement('TD');
			td5.innerHTML = '<input class="name" />';
		var td6 = document.createElement('TD');
			td6.innerHTML = '<input class="name" />';
		var td7 = document.createElement('TD');
			td7.innerHTML = '<input class="description" />';	
		//add the column cells to the row
		tr.appendChild(td1);
		tr.appendChild(td2);
		tr.appendChild(td3);
		tr.appendChild(td4);
		tr.appendChild(td5);
		tr.appendChild(td6);
		tr.appendChild(td7);
		
		//append the row to the table
		myTable.appendChild(tr);
	}
</script>
<table id='myTable'>
	<thead>
		<tr>
			<td>Name</td>
			<td>Date</td>
			<td>Project</td>
			<td>Hours</td>
			<td>Department</td>
			<td>Activity</td>
			<td>Description</td>
		</tr>
	</thead>
	<tbody>
	</tbody>
</table>


Any ideas how I do it please? Thanks
AnswerRe: How do I get the value of a drop down list into a javascript based table? Pin
Dennis E White11-Oct-11 19:45
professionalDennis E White11-Oct-11 19:45 
GeneralRe: How do I get the value of a drop down list into a javascript based table? Pin
shabbarank511-Oct-11 22:16
shabbarank511-Oct-11 22:16 
QuestionCreating a Javascript table and populating from php/mysql list Pin
shabbarank57-Oct-11 1:17
shabbarank57-Oct-11 1:17 
AnswerRe: Creating a Javascript table and populating from php/mysql list Pin
Manfred Rudolf Bihy7-Oct-11 2:31
professionalManfred Rudolf Bihy7-Oct-11 2:31 
GeneralRe: Creating a Javascript table and populating from php/mysql list Pin
shabbarank57-Oct-11 2:34
shabbarank57-Oct-11 2:34 
GeneralRe: Creating a Javascript table and populating from php/mysql list Pin
Manfred Rudolf Bihy7-Oct-11 3:06
professionalManfred Rudolf Bihy7-Oct-11 3:06 
AnswerRe: Creating a Javascript table and populating from php/mysql list Pin
Manfred Rudolf Bihy7-Oct-11 3:52
professionalManfred Rudolf Bihy7-Oct-11 3:52 
QuestionTrivial Pursuit Pin
goodideadave3-Oct-11 8:43
goodideadave3-Oct-11 8:43 
AnswerRe: Trivial Pursuit Pin
AspDotNetDev3-Oct-11 9:29
protectorAspDotNetDev3-Oct-11 9:29 
AnswerRe: Trivial Pursuit Pin
TheGreatAndPowerfulOz3-Oct-11 9:59
TheGreatAndPowerfulOz3-Oct-11 9:59 
GeneralRe: Trivial Pursuit Pin
goodideadave3-Oct-11 10:23
goodideadave3-Oct-11 10:23 
GeneralRe: Trivial Pursuit Pin
TheGreatAndPowerfulOz3-Oct-11 10:57
TheGreatAndPowerfulOz3-Oct-11 10:57 
GeneralRe: Trivial Pursuit Pin
goodideadave3-Oct-11 11:37
goodideadave3-Oct-11 11:37 
QuestionJavascript validation Pin
vanikanc29-Sep-11 10:19
vanikanc29-Sep-11 10:19 
GeneralRe: Javascript validation Pin
Shahriar Iqbal Chowdhury/Galib29-Sep-11 11:24
professionalShahriar Iqbal Chowdhury/Galib29-Sep-11 11:24 
AnswerRe: Javascript validation Pin
Graham Breach29-Sep-11 21:20
Graham Breach29-Sep-11 21:20 
GeneralRe: Javascript validation Pin
Manfred Rudolf Bihy29-Sep-11 22:31
professionalManfred Rudolf Bihy29-Sep-11 22:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.