By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,515 Members | 1,178 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,515 IT Pros & Developers. It's quick & easy.

i want get the value in dynamic from script

P: 1
<html>
<script language="text/javascript">
var test=DValue;
</script>
<body>
<inpu type="text" name="name" value="<script>test</script>" />
</body>
</html>

i want get the test "DValue" in dynamic.
test value will be changed dynamically...
Jun 22 '07 #1
Share this Question
Share on Google+
2 Replies


P: 18
You can achieve it by doing like this


<html>
<script language="text/javascript">
var test=DValue;
document.myForm.name.value=test;
</script>
<body>
<form name="myForm">
<inpu type="text" name="name"/>
</form>
</body>
</html>
Jun 22 '07 #2

gits
Expert Mod 5K+
P: 5,390
You can achieve it by doing like this


<html>
<script language="text/javascript">
var test=DValue;
document.myForm.name.value=test;
</script>
<body>
<form name="myForm">
<inpu type="text" name="name"/>
</form>
</body>
</html>
hi ... we have to correct some things here:

[HTML]
<html>

<script type="text/javascript">
function set_field() {
var test = 'DValue';
document.myForm.name.value = test;
}
</script>

<body onload="set_field();">

<form name="myForm">
<input type="text" name="name"/>
</form>

</body>

</html>[/HTML]

explaination: its the script-type to set, and we have to wrap the code in a function that we call onload of the body, until the textbox has to be loaded and rendered first by the browser. the way you want to do it ... means the script is executed during load ... before the document is ready to use ... so we wait for it and then call the set_field() method ... try it if you're wondering why it is not working. and DValue would be a variable in your code ... that is undefined here and the script will stop with an error for this ... so use a stringvalue here or declare the variable ... and assign a value to it ...

kind regards ...
Jun 22 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.