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;">
Result:
<div id="log" style="height: 200px; width: 300px; overflow: auto;"
class="ui-widget-content"></div>
</div>

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

</form>

<?php
if (!empty($_POST['city'])){
    print('<div>Latest submitted city was:
'.$_POST['city'].'</div>');
}
?>

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.