0

How can i send a value from my website to another website, i have a webiste1 and another website2 they have a same form with one textbox and one button and only the website1 is the only where Im going to enter and write some code and website2 is static and i will not going to mess the code of it, and after i enter a value from website1 this will going to send the value of it into website2 and website2 will open and i will see the value that i enter.

So far i have this

website1.html

<input type="text" name="cat-name" />
<input type="button" value="submit" onclick="foo()" />


function foo() {
    var cname = document.getElementsByName('cat-name')[0].value;
    //some code....
    location.href='website2.html?cat-name = cname';
    }

website2.html

<input type="text" name="cat-name" />
<input type="button" value="submit" onclick="sendtorealserver()" />
Trott
  • 66,479
  • 23
  • 173
  • 212
Max
  • 64
  • 2
  • 13

2 Answers2

1

Answered here: Persist javascript variables across pages?

Then you have to set the value:

<input type="text" name="cat-name" class="predefined"/>
<input type="button" value="submit" onclick="sendtorealserver()" />

and then

document.querySelector(".predefined").value = result;
Community
  • 1
  • 1
Vandervals
  • 5,774
  • 6
  • 48
  • 94
  • Hello are you referring for the website2 @Vandervals the website2 or page2 is not going to be modify only the website1 – Max May 14 '15 at 16:54
  • If site2 is not modifiable then they must have a way yo receive that Info. You should refer to that way and that of course will be diffetent forma every other other site – Vandervals May 14 '15 at 17:03
  • Yes, there is any way that the site2 can receive that info from website1 and will display the value of it into the textbox? – Max May 14 '15 at 17:08
  • Yes the site2 or website2 is not modifiable, and there is any way ? That if i click the submit button from site1 this will send the value into site2 and will display into the site2 textbox? Hope you can help me. – Max May 15 '15 at 02:32
-1

You will need to edit the window2.html to read the sent params and set it to the input; Pseudo code

window.onload = function(){{
  // read url params
  // set the value
  // document.getElementsByName('cat-name')[0].value = value_from_read_params
}

You can see how to get params from url here How to get the value from the GET parameters?

Community
  • 1
  • 1
roxxypoxxy
  • 2,973
  • 1
  • 21
  • 28