Connecting Tech Pros Worldwide Help | Site Map

pass value from one html page to another?

nirmalsingh's Avatar
Familiar Sight
 
Join Date: Sep 2006
Location: Madurai - India
Posts: 217
#1: Feb 14 '07
hai experts,
i am having page called main.html, when the user clicks a button in this page a popup window of pop.html is opened. in pop.html user enter his name and close that popup window.
now what i need is:
the name entered in pop.html shiould be shown as table format in main.html. the row should be added each and every time the user open and enter a name.
without refreshing main.html. what should i do for this.
dmjpro's Avatar
Lives Here
 
Join Date: Jan 2007
Location: India (West-Bengal)
Posts: 2,451
#2: Feb 14 '07

re: pass value from one html page to another?


plz try this code .......

in main.html
=================
Expand|Select|Wrap|Line Numbers
  1. //ur code
  2. <table id = my_tab>
  3. </table>
  4. //ur code
in pop.html
=================
Expand|Select|Wrap|Line Numbers
  1. <body onbeforeunload = passMain()>
  2. <input type = text id = ur_name>
  3. </body>

in pop.js file
==================
Expand|Select|Wrap|Line Numbers
  1. function passMain()
  2. {
  3.   var cell_obj = window.opener.document.getElementById('my_tab').insertRow().insertCell()
  4.   cell_obj.innerHTML = doument.getElementById('ur_name').value;
  5. }
  6.  
if u close or refresh the popup html the row will be inserted in main.html

plz send ur response

i am online
nirmalsingh's Avatar
Familiar Sight
 
Join Date: Sep 2006
Location: Madurai - India
Posts: 217
#3: Feb 14 '07

re: pass value from one html page to another?


no reaction in main.html.
my code:main.html
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <body>
  3. <table id = my_tab>
  4. </table>
  5. </body>
  6. </html>
pop.html
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <script language="javascript" src="pop.js">
  4. </script>
  5. </head>
  6. <body onbeforeunload = "passMain();">
  7. <input type = 'text' id = 'ur_name'>
  8. </body>
  9. </html>
pop.js
Expand|Select|Wrap|Line Numbers
  1. function passMain()
  2. {
  3. var cell_obj = window.opener.document.getElementById('my_tab').in sertRow().insertCell()
  4. cell_obj.innerHTML = doument.getElementById('ur_name').value;
  5. }
  6.  
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#4: Feb 14 '07

re: pass value from one html page to another?


In IE, you will need a tbody, so in main.html:
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <body>
  3. <table id = my_tab>
  4. <tbody id="mytb"></tbody>
  5. </table>
  6. </body>
  7. </html>
and in pop.js:
Expand|Select|Wrap|Line Numbers
  1. function passMain()
  2. {
  3. var cell_obj = window.opener.document.getElementById('mytb').insertRow().insertCell();
  4. cell_obj.innerHTML = doument.getElementById('ur_name').value;
  5. }
nirmalsingh's Avatar
Familiar Sight
 
Join Date: Sep 2006
Location: Madurai - India
Posts: 217
#5: Feb 14 '07

re: pass value from one html page to another?


still no reaction.
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#6: Feb 14 '07

re: pass value from one html page to another?


Sorry, typo. Try:
Expand|Select|Wrap|Line Numbers
  1. function passMain() {
  2. var cell_obj = window.opener.document.getElementById('mytb').insertRow().insertCell();
  3. cell_obj.innerHTML = document.getElementById('ur_name').value;
  4. }
dmjpro's Avatar
Lives Here
 
Join Date: Jan 2007
Location: India (West-Bengal)
Posts: 2,451
#7: Feb 14 '07

re: pass value from one html page to another?


always try to write while u coding js .........

Expand|Select|Wrap|Line Numbers
  1. try
  2. {
  3.  //ur code
  4. }catch(err)
  5. {
  6.  alert(err.description);
  7. }
then u can trap the error

now plz check out the case_sensitive id_name my_tab and mytb in main.html and pop.js
nirmalsingh's Avatar
Familiar Sight
 
Join Date: Sep 2006
Location: Madurai - India
Posts: 217
#8: Feb 15 '07

re: pass value from one html page to another?


hi experts,
can i send data from one html page to another just like
main.html?id=sample&data
if yes, how can i retrieve those data by javascript?
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#9: Feb 15 '07

re: pass value from one html page to another?


Use location.search and parse it for your values.
nirmalsingh's Avatar
Familiar Sight
 
Join Date: Sep 2006
Location: Madurai - India
Posts: 217
#10: Feb 16 '07

re: pass value from one html page to another?


hi experts,
i am having 2 html pages.
1.main.html
2.sub.html

in main.html, when i click a button, sub.html should open in a popup. the user will fill datas in sub.html and close the window. the filled data should be displayed as a table(in main.html along with edit and delete button on each row) at each and every time the user open popup and close. atlast i should be able to edit data by clicking edit button and popup should be opened to edit and after i close the popup, the edited data should be updated, and by clicking delete button current row should be deleted. and at final stage i need the datas in a string to save it in a database.
i hope u understood my problem.
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#11: Feb 16 '07

re: pass value from one html page to another?


You have already posted on this (though perhaps in this thread, you have given more information). Please do not double post. I am merging this with the previous thread.
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#12: Feb 16 '07

re: pass value from one html page to another?


Quote:

Originally Posted by nirmalsingh

hi experts,
i am having 2 html pages.
1.main.html
2.sub.html

in main.html, when i click a button, sub.html should open in a popup. the user will fill datas in sub.html and close the window. the filled data should be displayed as a table(in main.html along with edit and delete button on each row) at each and every time the user open popup and close. atlast i should be able to edit data by clicking edit button and popup should be opened to edit and after i close the popup, the edited data should be updated, and by clicking delete button current row should be deleted. and at final stage i need the datas in a string to save it in a database.
i hope u understood my problem.

Why go through the hassle of passing values between pages? Just allow the user to edit values directly in the page by showing a text box with the value when you click on edit. Alternatively, just show a prompt box and use the edited value to dynamically change the current value.
nirmalsingh's Avatar
Familiar Sight
 
Join Date: Sep 2006
Location: Madurai - India
Posts: 217
#13: Feb 19 '07

re: pass value from one html page to another?


hi all! i need a popup box to enter values. it should be cross browser compatibility. what should i do?
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#14: Feb 19 '07

re: pass value from one html page to another?


Merged threads. Follow the suggestion that I posted earlier in this thread. If you still have problems, post your code.
Newbie
 
Join Date: Oct 2009
Posts: 2
#15: 4 Weeks Ago

re: pass value from one html page to another?


Hi,

I have a question regarding this passMain function,
Unfortunately I cant reach my admin, How can I allow my members to download the .wmv file from this code:

Expand|Select|Wrap|Line Numbers
  1. <img onmouseout="                  swapImage(vid_5738, '/web/vod/images/5738.png')
  2.                 " onmouseover="                  swapImage(vid_5738, '/web/vod/images/5738NAV.png')
  3.                 " onclick="                  passMain('5738', 'http://38.117.88.50/N/TV_Series/BooyeGolhayeVahshi/BooyeGolhayeVahshi_01.wmv', 'WB100619');window.parent.chName='Booye Golhaye Vahshi - 1';
  4.                 " style="position: absolute; top: 8px;" src="/web/vod/images/5738.png" name="                  vid_5738" id="vid_5738" class="logo"/>
Before it used to be the file.wmv?sid=value&vid=value
But it wont work now, please help me with this issue
Newbie
 
Join Date: Oct 2009
Posts: 2
#16: 4 Weeks Ago

re: pass value from one html page to another?


Would someone please answer my question ?!
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#17: 4 Weeks Ago

re: pass value from one html page to another?


Can you post your version of passMain() and also check if you have any errors?
Reply