answersLogoWhite

0


Best Answer

You would have to do this using an AJAX request. The onchange event would trigger a Javascript function that would in turn send a request to the server, and handle the response.

This requires a fair bit of back-end code for handling the AJAX, and I would recommend using an existing library for that purpose. jQuery is the one that I am familiar with, and you could handle that change event like so:

<?php

if(array_key_exists('mytext', $_POST)){

echo "The text you posted is "{$_POST['mytext']}"";

exit;

}

?>

<script src="(jquery source URL here)" type="text/javascript"></script>

<!-- ... -->

<input type="text" id="mytext"></input>

<div id="result"></div>

<script type="text/javascript">

$("#mytext").change(function(){

$.post("myscript.php", {'mytext':$("#mytext").val()}, function(dat){

$("#result").HTML(dat);

});

});

</script>

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you call a PHP function from an onchange equals in an HTML form?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Where are scripts placed in an HTML document?

you can put your script into a function. A function contains code that will be executed by an event or by a call to the function.


Which function call Does not consume stack space?

Calling an in-line function, which is not actually a function-call.


How do you add textbox when options is selected using javascript?

The best way to add a test box based on an option chosen from a select box is to modify the DOM to show the element. You can accomplish this by adding the text box to the DOM when the option is selected, or by having it already there, but hidden, until the option is selected. Here is some sample code to show the text box only when Option 7 is chosen. Feel free to modify it to suit your needs: &lt;select onchange="if (this.value 7) { document.getElementById('textbox1').display = 'inline'; } else { document.getElementById('textbox1').display = 'none'; }"&gt; &lt;input type="text" id="textbox1" name="textbox1" style="display: none;"&gt; Both of these methods can also be used by creating a JavaScript function to handle the actual procedure, and the onchange attribute can simply call that function. You can use arguments to the function to encapsulate and reuse the code for other elements on your page.


What is the syntax to call a jsp page from HTML button?

There are several ways to use an HTML button to go to a web page. You can keep it simple. This example uses "page.jsp" in the same directory as your HTML page for your target location. You can use the following code:


What do you call the links between the pages or other websites in HTML?

Links in HTML documents are called references. They are commonly known as href's, or HyperText References.

Related questions

Where are scripts placed in an HTML document?

you can put your script into a function. A function contains code that will be executed by an event or by a call to the function.


How do you use a function with a button in PHP?

A simple function call &lt;html&gt; &lt;body&gt; &lt;?php if(isset($_POST['button'])) { setValue(); // Function is called } function setValue() { echo "&lt;br&gt;The button property to call PHP function works"; // Your code here } ?&gt; &lt;input type="submit" name="button" onclick=&lt;?php $_SERVER['PHP_SELF']; ?&gt; /&gt; &lt;/body&gt; &lt;/head&gt;


What function in Microsoft Excel 2003 to write the amount in word?

Such a function does not exist for English. A function call BAHTTEXT will do it for the Thai language.Such a function does not exist for English. A function call BAHTTEXT will do it for the Thai language.Such a function does not exist for English. A function call BAHTTEXT will do it for the Thai language.Such a function does not exist for English. A function call BAHTTEXT will do it for the Thai language.Such a function does not exist for English. A function call BAHTTEXT will do it for the Thai language.Such a function does not exist for English. A function call BAHTTEXT will do it for the Thai language.Such a function does not exist for English. A function call BAHTTEXT will do it for the Thai language.Such a function does not exist for English. A function call BAHTTEXT will do it for the Thai language.Such a function does not exist for English. A function call BAHTTEXT will do it for the Thai language.Such a function does not exist for English. A function call BAHTTEXT will do it for the Thai language.Such a function does not exist for English. A function call BAHTTEXT will do it for the Thai language.


Does HTML have anything to do with Software development?

No, HTML relates to passing information across the www. Software can be developed to edit HTML, and HTML can be used to call software (java) but you can't write 'OpenOffice' using an HTML editor.


What is meant by a function call?

A function call is where you "call" a function and execute its body. For example: void example() { } int main() { example(); // call the function "example" and execute its bodyreturn 0; }


Which function call Does not consume stack space?

Calling an in-line function, which is not actually a function-call.


What is if function withan an if function call?

A nested function.


How does you call javascript file in css?

In your HTML add in the tags


How do you add textbox when options is selected using javascript?

The best way to add a test box based on an option chosen from a select box is to modify the DOM to show the element. You can accomplish this by adding the text box to the DOM when the option is selected, or by having it already there, but hidden, until the option is selected. Here is some sample code to show the text box only when Option 7 is chosen. Feel free to modify it to suit your needs: &lt;select onchange="if (this.value 7) { document.getElementById('textbox1').display = 'inline'; } else { document.getElementById('textbox1').display = 'none'; }"&gt; &lt;input type="text" id="textbox1" name="textbox1" style="display: none;"&gt; Both of these methods can also be used by creating a JavaScript function to handle the actual procedure, and the onchange attribute can simply call that function. You can use arguments to the function to encapsulate and reuse the code for other elements on your page.


What do you call the inverse function of the exponential function?

Logarithmic Function


What is Bios function call in 8086 microprocessor?

The BIOS function in the 8086 microprocessor is called an interrupt function. It is an interrupt function because it is not called by a function call instruction.


Are there websites that convert pictures to HTML?

No. HTML itself doesn't have the ability to display images, except by having the browser call them as an external resource.