I have a grid and a textarea.When I click on a line from the grid ,in the textarea control I put some informations and I want this textarea to be in the front of the page , because my grid have multiple lines and my textarea is down on the page. The definition for textarea is this:
<textarea id="BodyMessDetailed" cols="20" name="S1" rows="10" readonly="readonly" tabindex="1" >
<%=DefaultVal%>
</textarea>
In the row definition I call ShowBodyFunction:
<tr onclick ="javascript:ShowBody('B<% = Model.Id %>')"> ....
ShowBodyFunction is :
function ShowBody(stringId) {
var obj1
var obj2
obj1 = document.getElementById(stringId);
obj2 = document.getElementById("BodyMessDetailed");
obj2.innerText = obj1.innerText;
obj2.select();
obj2.focus();
}
I observed that if I click on the line of the grid and after that I press backspace the application does what I want ,but I don't know how to make this from application .I tried with : onclick ="javascript:ShowBody('B<% = Model.Id %>');tab char;" >
but doesn't work.Can somebody tell my which is the solution?
Can somebody tell me how to call a backspace or a tab after I call the 'ShowBody' function?
try replacing innerText method by innerHTML and comment the obj.select() method. If it doesn't works after that tell me.
please make one more change - replace: ')"> by:
<tr onclick="ShowBody(this.id)" id="" .....
The 'id' attribute is mandatory in the 'TR' element.
Hope it works this time :)
in the function showBody , comment everything you have previously written and
just put an alert(StringID);
inside it and see if the function is getting called or not.
If the function is not getting called there is no use of looking what's written inside it.
If the alert dialog shows up during the runtime, then we will look into actual code inside
ShowBody. I'm online :) .
Just make use of value
its working fine.
function ShowBody(stringId) {
alert(stringId); // showing the output
var obj1 = document.getElementById(stringId);
var obj2 = document.getElementById("BodyMessDetailed");
obj2.value = obj1.value;
obj2.select();
obj2.focus();
obj2.scrollIntoView();
}
put a semicolon
in function call
in tr
.
<tr onclick ="ShowBody('B<% = Model.Id %>');">
attaching screen shot for your reference
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.