473,398 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

what will this do?

19
document.getElementById('util_overview').innerHTML = "";
May 21 '10 #1
9 1385
nukefusion
221 Expert 100+
Attempt to find an HTML element on the page with an id value of "util_overview" and set the content between the tags to an empty string.

For example, say you had an HTML page with this:

Expand|Select|Wrap|Line Numbers
  1. <div id="util_overview">
  2.     <div id="some_other_div">
  3.         This is some random text
  4.     </div>
  5. </div>
  6.  
What you'd end up with, would be this:

Expand|Select|Wrap|Line Numbers
  1. <div id="util_overview"></div>
  2.  
May 21 '10 #2
gits
5,390 Expert Mod 4TB
this wipes out the nodes that the node with the id='util_overview' would contain ...

kind regards

PS: ahh ... one second late :)
May 21 '10 #3
techuse
19
@nukefusion
how can i refresh a particular div?
May 21 '10 #4
nukefusion
221 Expert 100+
If you want to change the contents of a particular div, the code you posted will do the job. Just assign some new, valid HTML to the innerHTML property instead of an empty string.

Of course, you'll need a way of initiating the change, such as wiring up your JS function to an event.
May 21 '10 #5
techuse
19
@nukefusion
Expand|Select|Wrap|Line Numbers
  1. /* -------------------------- */
  2. /* INSERT VACATION */
  3. /* -------------------------- */
  4. /* Required: var nocache is a random number to add to request. This value solve an Internet Explorer cache issue */
  5.  
  6.  
  7.  nocache = 0;
  8.  progress_bar = new Image();
  9. progress_bar.src = '../HRManagement/images/ajax-loader.gif';
  10.  
  11.  
  12. function success_handler(o) {
  13.   replace_html('leaveinserting', o.responseText);
  14.         }
  15.  
  16.         function failure_handler(o) {
  17.             replace_html('leaveinserting', 'Server or your connection is death');
  18.         }
  19.            function replace_html(id, leaveinserting) {
  20.         document.getElementById(id).innerHTML = leaveinserting;
  21.         }
  22.         function show_progressbar(leaveinserting) {
  23. replace_html(leaveinserting, '<img src="/HRManagement/images/ajax-loader.gif" border="0" alt="Loading, please wait..." />');
  24.         }
  25. function insert(Divid,emp,req,type,start,end,total,clr) {
  26.  
  27.  
  28.     alert("Inside the script");
  29.     alert("progressbar");
  30.     show_progressbar('leaveinserting');
  31.  
  32.     alert("DivID :"+Divid)
  33.     alert("emp :"+emp)
  34.     alert("req  :"+req)
  35.     alert("type :"+type)
  36.     alert("start :"+start)
  37.     alert("end :"+end)
  38.     alert("total :"+total)
  39.     alert("clr:"+ clr)
  40.  
  41.  
  42.  
  43. var Divid = Divid;
  44. var emp  = emp;
  45. var req  = req;
  46. var type = type;
  47. var start = start;
  48. var end = end;
  49. var total = total;
  50. var sta = "E";
  51.  
  52.  
  53. //document.getElementById('leaveinserting').innerHTML = "Just a Second... ";
  54.  
  55. nocache = Math.random();
  56. alert("nocache="+nocache)
  57.  
  58. //alert("progressbar");
  59. //show_progressbar('inserting');
  60. //var callback = { success:success_handler,    failure:failure_handler, timeout: 10000 };
  61.  
  62. searchReq.open('get','leaveinsert.jsp?EMPLOYEE_LEAVE.EMPLOYEE_ID='+emp+'&EMPLOYEE_LEAVE.REQUEST_DATE='+req+'&EMPLOYEE_LEAVE.LEAVE_TYPE='+type+'&EMPLOYEE_LEAVE.START_DATE='+start+'&EMPLOYEE_LEAVE.END_DATE='+end+'&EMPLOYEE_LEAVE.TOTAL_DAYS='+total+'&EMPLOYEE_LEAVE.STATUS='+sta+'&mode=insert');
  63. //searchReq.open('get','employeeleaveoverview.jsp?EMPLOYEE_LEAVE.EMPLOYEE_ID='+emp+'&EMPLOYEE_LEAVE.REQUEST_DATE='+req+'&EMPLOYEE_LEAVE.LEAVE_TYPE='+type+'&EMPLOYEE_LEAVE.START_DATE='+start+'&EMPLOYEE_LEAVE.END_DATE='+end+'&EMPLOYEE_LEAVE.TOTAL_DAYS='+total+'&EMPLOYEE_LEAVE.STATUS='+sta+'&mode=insert');
  64.  
  65.  
  66. searchReq.onreadystatechange = insertleaveReply;
  67. searchReq.send(null);
  68. //form.reset();
  69. }
  70.  
  71. function insertleaveReply() {
  72. if(searchReq.readyState == 4){
  73. var response = searchReq.responseText;
  74.  
  75.  
  76. // else if login is ok show a message: "Site added+ site URL".
  77. document.getElementById('leaveinserting').innerHTML = 'Inserted'+response;
  78. document.getElementById('clearing').innerHTML = "";
  79. alert("Response"+ responseText);
  80. document.getElementById('leaveinserting').innerHTML = responseText;
  81. }
  82.  
  83. }
May 21 '10 #6
techuse
19
@nukefusion
i have the two div in a same page.first div having list.second div having inserting ethod.after inserting the recod have to refresh the first div. how to refresh the first div?
May 21 '10 #7
nukefusion
221 Expert 100+
Well, presumably, within your second div you will have some sort of input field and a button. You could wire up a JS function to the buttons click event and using it add the input field content to your first div. Using the getElementById method you could do something like this for example:

HTML:

Expand|Select|Wrap|Line Numbers
  1. <div id="div1">
  2.  
  3. </div>
  4. <div id="div2">
  5.     <textarea name="data" rows="3"></textarea>
  6.     <input type="button" value="Add to div1" onclick="addToDiv1()" />
  7. </div>
  8.  
javascript:

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2.     function addToDiv1() {
  3.         var div1 = document.getElementById("div1");
  4.         div1.innerHTML = document.getElementById("data").value; 
  5.     }
  6. </script>
  7.  
I haven't got time to test this code right now but the prinicipal is there. If I've understood your question properly then you can easily adapt this to achieve the result you're after.

Hope this helps.
May 21 '10 #8
techuse
19
I have a jsp page in which ther r 2 divs.

In the first one ,there is a list which gives the records inserted from the second div.

In the 2nd div,there r some textboxes.I got the value thr document.getElementbId
method and inserting the values thr ajax script.

On successful insertion of data into the table,the first div should be refreshed
showing recent added records and the second div data should be cleared or reset.

can give me any suggestion in solving the problem.Document1.txt


*****hereby attached the ajax script for inserting the values.
May 21 '10 #9
nukefusion
221 Expert 100+
Without the associated html it's hard to see how this all links up.

If you doing some work using AJAX you can add any code to refresh the div in the callback method (success_handler). It looks like you've already got it setup to do something like this as it's already updating the "leaveinserting" div with the return value anyway.

I'm not quite sure what part of your process isn't working... it looks like all the ingredients are there.
May 21 '10 #10

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

Similar topics

3
by: Kelvin | last post by:
Hi, there: My question is, what if my text contains the tag in square bracket itself? What will MSXML30.dll do with such situation? Do I have to filter out these stuff before I save the XML file...
18
by: Xiangliang Meng | last post by:
Hi. void setValue(int n) { int size = getValueLength(); int buffer_p; if (buffer_p) { ....
5
by: Raj Sharma | last post by:
Hai Guys, I am new to the group well i have one doubt in my mind from a long time, that what will be the Future of VC++, as full framework has been now .NET so will it be easy to shift to C#, or...
4
by: Anil | last post by:
Question related to ASP.Net web application with .Net Framework 1.1. I am using ADO.Net and ODBC namespace. When the user clicks the process button I am doing database INSERT/UPDATRE.....
67
by: neilcancer | last post by:
i come from china,and i'm sorry that my english is very poor. now i'm studing data structure and i met some problem about c language. could you tell me what will happen after i use free()? i...
17
by: Ravi | last post by:
void main() { main(); } int main() { main(); }
14
by: raghu | last post by:
Hello I have a doubt plz clarify that #ifndef SYSTEM_H #define SYSTEM_H what will be the value of SYATEM_H after this #define statement and before that statement. Thanking you all Bye
3
by: vimalankvk80 | last post by:
what will happen, if we forget to return ostream referance ? class A { Private: int _a; int _b;
11
by: active | last post by:
If I install .NET Framework 3.0 what will happen to my VS2005 experience? Will it automatically use 3.0? Will I find new features available? Will the VS doc be updated? Thanks fir any...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.