Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change(this) in input field => get properties from 'this' in script

Status
Not open for further replies.

Promajo

Programmer
Oct 1, 2002
3
BE
i replaced < with [ and > with ]


my problem:
when you change something in the input field, I want to know what is the value of the input and change the style according to the given input; how can I do this, I want to use a Change(this) function which would work for every input field; so &quot;alert(this.value);&quot; wont give the value from the input field [problem 1] and don't knwo if this works &quot;style.td.tdclass = this.value;&quot; [problem 2]



HTML:
...

[style]
td.tdclass
{
font-family: &quot;Times New Roman&quot;, Times, serif;
font-size: 15px;
color: #FFFFFF;
font-style: normal;
font-weight: 600;
}
[/style]

[script language=&quot;javascript&quot;]
function Change()
{
alert(this.value);
// style.td.tdclass.color = '#' + this.value;
}
[/script]

...

[form name=&quot;frmName&quot;]
...
  [td class=&quot;tdclass&quot;]
    [input type=&quot;text&quot; name=&quot;inpName&quot; onchange=&quot;javascript: Change(this);&quot;]
  [/td]
...
[/form]

...
 
You could put the html in a span or div and use .innerHTML to change the class. For example:

function Change(){
form.document.all('dynamTD').innerHTML =
'<td class=&quot;tdnewclass&quot;>' +
.....;
}
</script>


<span id=&quot;dynamTD&quot;>
<td class=&quot;tdclass&quot;>
<input type=&quot;text&quot; name=&quot;inpName&quot; onchange=&quot;javascript: Change(this);&quot;>
</td>
</span>


 
is there any other way because I have a lot of those edit fields on a page and the innerhtml would be a couple of pages long

the example I used was the most simple form I could make from the complete one
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top