Jump to content

sankar_bhatta

Members
  • Posts

    10
  • Joined

  • Last visited

sankar_bhatta's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. HIwe use "src" in <img> tag and in <frame> tag. If i want to assign a html file or .jpg to this "src" element, what should i write. can i write src = "c/documents and settings/desktop/image.jpg". How do i inlcude files in the local pc.thankssankar
  2. Hi Jesh,Thank you very much. I am now able to get the selected values from the child window to parent window. I really appreciate ur help. I will be back with more queries :) thankssankar
  3. HI Jesh,I was successful to some extent ,but not completely. In the below code in function "whichelement" i have alert statement todetermine what are the values that are passed to the parent window. When I put the alert(tvalue) in function i got undefined as the output.I think using the targ.value will not fetch the value of the cell on which i have clicked. How do i get the value in the cel on which i have clicked. <html><head><script type="text/javascript">var tvalue ;var tname;function whichelement(e){var targ;if(!e) var e = window.event;if (e.target ) targ = e.target;else if (e. srcElement ) targ = e.srcElement;tname=targ.tagNameif(tname== "td" || tname == "TD") { // OK, the element that sent the event was a td element. // now we can update the content of the text input.tvalue = targ.value;alert(tvalue); document.getElementById("field").value = tvalue; }}function createNewDoc() { var newwindow=window.open(); var txt="<html><body onmousedown = window.opener.whichelement(event)><table border = 1 id = cells><tr><td>ABC</td><td>good</td></tr>";txt +="<tr><td>123</td><td>verygood</td></tr></table></body></html>"; newwindow.document.write(txt);<!-- var x = newwindow.document.getElementById("cells").rows[0].cells; --><!-- var firstcell = x[0].innerHTML; -->//document.getElementById("field").value = tvalue; }</script></head><body><input type = "text" id = "field"><input type="button" value="Open and write to a new document" onclick="createNewDoc()"></body></html>
  4. Hi Jeshthank you very muchI am now able to populate the cell values from child window to the aprent window. Now my problem is I want to populate the value of a cell on which I have clicked. How do i find out on which element I have clicked. I have taken the reference of an example from w3schools http://www.w3schools.com/js/tryit.asp?file...vent_srcelementI have written the code as below , but it si not working. please suggest a way out. <html><head><script type="text/javascript">var tvalue ;function whichelement(e){var targ;if(!e) var e = window.event;if (e.target ) targ = e.target;else if (e. srcElement ) targ = e.srcElement;tvalue = targ.value;}function createNewDoc() { var newwindow=window.open(); var txt="<html><body onmousedown = whichelement(event)><table border = 1 id = cells><tr><td>ABC</td><td>good</td></tr>";txt +="<tr><td>123</td><td>verygood</td></tr></table></body></html>"; newwindow.document.write(txt);document.getElementById("field").value = tvalue; }</script></head><body><input type = "text" id = "field"><input type="button" value="Open and write to a new document" onclick="createNewDoc()"></body></html>
  5. Hi Jeshthank you verymuch for your reply. The problem is solved.I am moving to another step further and modify my program. Now I want to have a table in the child window with 2 rows and 2 cells . When I click on any of the cell the content of the cell should be copied to the input element in the parent window. I have first tried to create the table in the child window when i click on the button in parent window. i have written the code as below. It is not working. pelase let me know what is to be done and how do i bring the each cel content on which i have clicked to the input field in the parent window. <html><head><script type="text/javascript">function createNewDoc() { var newwindow=window.open(); var txt="<html><body><table><tr><td>ABC</td><td>good</td></tr><tr><td>123</td><td>verygood</td></tr></table></body></html>"; newwindow.document.write(txt); }</script></head><body><input type = "text" id = "field"><input type="button" value="Open and write to a new document" onclick="createNewDoc()"></body></html> thankssankar
  6. Hi Jesh,Thanks for your reply.I have wirtten the code as you said ,but the problem is whenever I click on the button in the parent window, a window is opening and the test field in the parent window is filled with "undefined". My requirement is ti fill the input field with words written in the new window. I am giving the code here. please suggest the corrections. <html><head><script type="text/javascript">function createNewDoc() { var newwindow=window.open(); var txt="<html><body>Learning about the DOM is FUN!</body></html>"; newwindow.document.write(txt);var newtext = newwindow.document.innerHTML;document.getElementById("field").value = newtext; }</script></head><body><input type = "text" id = "field"><input type="button" value="Open and write to a new document" onclick="createNewDoc()"></body></html> what i want here is the input field "field" should be filled with the sentence " Learning about the DOM is fun!". Instead of that it is coming as "undefined".thankssankar
  7. HiSomebody please give solution to my problem.thankssankar
  8. HI jeshthanks for the replyI have written the code as below. <html><head><script type="text/javascript">function createNewDoc() { var newwindow=window.open(); var txt="<html><body>Learning about the DOM is FUN!</body></html>"; newwindow.document.write(txt);var parent = window.opener;var newtext = newwindow.document.innerHTML;parent.document.getElementById("field").value = newtext; }</script></head><body><input type " "text" id = "field"><input type="button" value="Open and write to a new document" onclick="createNewDoc()"></body></html> PLease let me know what is going wrong. The value is not getting transferred to the parent window.thankssankar
  9. Hi guys,I have started learning javascript recently. I am tring to build a smal program. the requirement is like thisI will ener into one page where i have button and an input field. When I clcick on the button a new window should open and this window inturn shoud contain a table with several rows and columns. probably like thisA | 1233 | dfgfdg----------------------------------B | 12313 | fgfg-----------------------------------C | 121 | fgfgf-----------------------------------So in the second window when i click on A , the program should go to the first window and place the A in the input field in the first window.I have succeded to some extent but could not bring back the values to the first window.can anybody please provide the code for the above requirement..thanks in advancesankar
×
×
  • Create New...