Results 1 to 3 of 3
- 07-13-2009, 07:13 PM #1
Member
- Join Date
- Jul 2009
- Posts
- 2
- Rep Power
- 0
PHP dynamic Select in a Java script
Help please, I am very new to PHP and Java, I have been asked to make a time card page for our employees to enter there times daily. I made a form that uses Java to dynamically generate the required time card questions.. “Job Number, Drawing Number, Work Step, Quantity and Time spent.” At the push of a button. So the employee can add one job or many if needed. I got that part to work. Now the problem I run in to is I need to have a Selection box for “Job Number” and “Work Step” dynamically populated from a PHP query of the data base. So as we add / remove Job Numbers or Work Steps thay show up on the fly so I don’t have to up date the code ever time a change is made.
Here is my java code. Warning it’s sloppy; it adds two sets of tables with the questions needed. I put <!!!!DYNAMIC SELECT BOX HERE!!!!> where I would like the PHP results to be.
Here is my PHP code:Java Code:function addInput(divName, inputType){ var newdiv = document.createElement('div'); newdiv.innerHTML = "<table width='632' border='1'><td width='30%'><table width='307' height='129' border='1'><tr><td width='49%'><strong>Job Number:</strong></td><td width='51%'><input type='text' name='JobNumber[]'></td></tr><tr><td><strong>Drowing Number:</strong></td><td><input type='text' name='DrowingNumber[]'></td></tr><tr><td><strong>Work Step:</strong></td><td> <!!!!DYNAMIC SELECT BOX HERE!!!!> </td></tr><tr><td><strong>Quantity:</strong></td><td><input type='text' name='Quantity[]'></td></tr><tr><td height='23'><strong>Time:</strong></td><td><input type='text' name='Time[]'></td></tr></table></td><td width='70%'><table width='308' height='129' border='1'><tr><td width='49%'><strong>Job Number:</strong></td><td width='51%'><input type='text' name='JobNumber[]'></td></tr><tr><td><strong>Drowing Number:</strong></td><td><input type='text' name='DrowingNumber[]'></td></tr><tr><td><strong>Work Step:</strong></td><td><!!!!DYNAMIC SELECT BOX HERE!!!!> </td></tr><tr><td><strong>Quantity:</strong></td><td><input type='text' name='Quantity[]'></td></tr><tr><td height='23'><strong>Time:</strong></td><td><input type='text' name='Time[]'>"; document.getElementById(divName).appendChild(newdiv); counter++;
Now both by them self work but I need help getting them to work to gather. Or if you know a better way.Java Code:mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error()); mysql_select_db($dbname) or die(mysql_error()); $query = "SELECT DISTINCT name FROM work_steps where active='1' ORDER BY name"; $result = mysql_query($query); <? print "<SELECT class='element select medium' name=Work Step size=10>"; while ($line = mysql_fetch_array($result)) { foreach ($line as $value) { print "<OPTION value='$value'"; } print ">$value</OPTION>"; } mysql_close($link); print "</SELECT>";?>
-
This is not Java, but rather is JavaScript which is a completely different language. You may have some folks who know about this here, but you could be better off looking for a JavaScript site. Best of luck.
- 07-13-2009, 08:16 PM #3
Member
- Join Date
- Jul 2009
- Posts
- 2
- Rep Power
- 0
Similar Threads
-
java script
By satti in forum Web FrameworksReplies: 0Last Post: 06-09-2009, 08:53 AM -
How to retain value in struts 2 using <s:select></s:select> tag
By SaiPrasad@Sella in forum Web FrameworksReplies: 0Last Post: 02-09-2009, 07:23 AM -
run perl script from java
By maheshmhs in forum New To JavaReplies: 0Last Post: 12-19-2008, 12:40 PM -
how to SELECT LAST_INSERT_ID() in java
By int80 in forum JDBCReplies: 3Last Post: 08-26-2008, 04:43 AM -
Displaying a Java List in Html:select tag
By ramitmehra123 in forum New To JavaReplies: 0Last Post: 02-07-2008, 05:48 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks