on 2005 Oct 05 9:27 PM
Hello!
I'm trying to set a value in Java Script dynamically and running in to some snags.
<script language="JavaScript" type="text/javascript">
function fnShowText(txt)
{
var x = document.getElementById(txt);
var y = "select1b";
var sText = x.options.value;
document.mainform.select1b.value = sText;
}
</script>
On the last line "document.mainform.select1b.value = sText"
I want to be able to set this value dynamically. Meaning is there way to make the select1b part a variable? This select1b is an htmlb input field. I'm trying to set that to a selected value in a drop down box. This works if I type in the statement above. But when I try to code like this I have issues:
a = "select1b"
document.mainform.a.value = sText;
I understand that select1b is an object so this won't work, but any ideas on how I can try to implement this?
Thanks in advance,
Eric
Hi,
It depends upon how u r calling the Javascript .
For example ,if the value of the txt is changing for each page refresh ..
set
txt = <% = bspvariablename %>
function fnShowText(txt)
{
var x = document.getElementById(txt);
var y = "select1b";
var sText = x.options.value;
document.mainform.select1b.value = sText;
}
Rgds,
J
Do Award pts if this is helpful.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
just in the onclientselect of the dropdownlistbox run a javascript to set it for the inputfield.
onclientselect="javascript:myfunc(this.myform.<ddl id>.options[this.myform.<ddl id>.selectedIndex].value);"
<script>
myfunc(val){
document.myform.<inputfieldid>.value = val ;
}
</script>
Hope this helps.
Regards
Raja
User | Count |
---|---|
70 | |
10 | |
10 | |
7 | |
6 | |
6 | |
6 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.