Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
So maybe I am using the wrong keywords on Google but I can find how to...
Take a value generated by Java script and put into a HTML input value. My attempted code may make more sense. I am attempting to generate a random ID to be placed in an input value field that is non-editable. So...
HTML Code
<td><input type="text" name="itemID" size="20" disabled="disabled" value=" '+ID+' ">
Java Script
<script type="text/javascript">var d = new Date()
var ID = d.getDate()+""+d.getMonth() + 1+""+d.getFullYear()+""+d.getHours()+""+d.getMinutes()+""+d.getSeconds();
document.write(ID );
ORdocument.write("<INPUT name=\"itemID" + "value=\" + "ID" + " + ">" );
OR a series of
document.write(" <INPUT name=\"q")
document.write(i)
document.write("\" value=\"\">")</script>
I figure this would be fairly easy to do. Let me know if you know anything.Thanks.
ASUS M2N-SLI
2 gb RAM ATI,
AMD 5200
Thermaltak SVKing Case
XFX 7600 GT
550W Antec TruPower

If you're trying to set a dynamic id in the html so that if its posted back the value goes with it then you can try:
1) Adding a hidden field to the html
<input type="hidden" name="dynamicId">2) Set the value in the javascript:
document.formname.dynamicId.value = ID;Obviously the html structure you use will effect how you can access the dynamicId field but hopefully this should help.
RB

Do you mean something like below?
<html> <head> <script language="javascript"> function randID() { var d = new Date(); document.getElementById("locked").value = Math.ceil(Math.random() * d.getTime()); } </script> </head> <body onload="randID()"> <input id="locked" value="" disabled="disabled"> </body> </html>

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |