0

So I have this input:

<input type="text" id="url" onchange="update(this.value)">

what I want to do is when this input change, the value will be taken to another input but before that I need to make a php function on it.

so I thought on something like this:

function update(url)
{
     var src = <?php echo json_encode(getUrl(*****url*****)) ?>;
     document.getElementById("src").value = src;
}

but since the url variable is in js I cant send it in php.

any suggestions?

3
  • You need to use Ajax to communicate between the web page and php. Commented Sep 13, 2013 at 0:56
  • I tried to do the few I know with ajax, but I dont know enough, can you help me with this? Commented Sep 13, 2013 at 1:04
  • does text input has an event onchange? Commented Sep 13, 2013 at 9:21

2 Answers 2

1

As it was pointed out already you have to use Ajax to communicate with your PHP script. Have a look at this http://fiddle.jshell.net/Qvqha/

Sign up to request clarification or add additional context in comments.

Comments

0

If you want to call PHP function. Then that function should be in PHP code.

If you want to pass text box variable to another place on change event, then you need to use ajax call.

Check this link:

PHP: get the value of TEXTBOX then pass it to a VARIABLE

2 Comments

how do I send the getUrl function a value than?
yes, I want to send the value which you type and than to take the returned value to another text box and div.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.