w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How can I turn the result of this javascript into a php variable?

If you want to use this nifty piece of code for filling a form, what user can submit and php can work with on serverside, then you have to make it a form and give city field an appropriate name:

<form method="post">

<div class="ui-widget">
<label for="city">Your city: </label>
<input id="city" name="city" />
<div class="ui-widget" style="margin-top: 2em; font-family: Arial;">
<div id="log" style="height: 200px; width: 300px; overflow: auto;"

<input type="submit" value="ok" />


if (!empty($_POST['city'])){
    print('<div>Latest submitted city was:

Put this amended stuff (together with javascript) into a .php file and point your browser to this.

© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.