0

I have 2 php pages. Let's name it page1.php and page2.php. On page1.php is a textbox with the value of 0, and on page2.php is a button. Now these two pages are open in different tabs in a browser. What I want to happen is whenever the button in page2.php is clicked the textbox value in page1.php will change to 1. Note that I want this process to happen without redirecting or refreshing the pages.

page1.php

<script type="text/javascript" src="jscript.js">
<input type="text" value="0" id="txt1">

page2.php

<script type="text/javascript" src="jscript.js">
<input type="button" value="change text1 value" onClick="changeval()">

jscript.js

function changeval(){
document.getElementById('txt1').value="1";
}

I wanna change the value of textbox through it's id. My professors gave me a hint that this could be done using javascript/jquery or ajax. Any help would be much appreciated.

clyde
  • 61
  • 2
  • 9
  • 2
    3 choices - repeating AJAX calls, cookies or [HTML5 storage events](http://html5demos.com/storage-events) – Zathrus Writer Oct 10 '13 at 13:55
  • http://stackoverflow.com/questions/5149080/how-can-i-update-value-of-input-text-via-ajax Check out the last answer, it should be helpful – Rohit Oct 10 '13 at 14:38

1 Answers1

0

You can use local storage in html. http://diveintohtml5.info/storage.html. See the event section. As long as both pages are on the same domain, you should be able to get data from one page to another without having to refresh or change the page.

bosspj
  • 80
  • 6