craigafer Posted September 12, 2010 Share Posted September 12, 2010 well i got more questions since i started at javascript and now im currently practicing php my question is whats the equivalent of this lines of codes to php language? document.getElementById("txt1").value <input type="button" name="one" id="one" value="1" onclick="javascript:getvalue(1);"\> == well what i mean is can i pass value to php functions every time i click it? just like calculators OT: can some1 help me translating my js calcu codes to php ones? document.getElementById("txt1").value this is my main problem i cant display the buttons i click Quote Link to comment Share on other sites More sharing options...
OOP Posted September 12, 2010 Share Posted September 12, 2010 Hi there, Javascript is a client side scripting language so there is no interaction between the client ( browser ) and the server. However, PHP is a server side scripting language so your browser send a request to the server, the server evaluate and process your request and the send the response to the browser again. In PHP, you can get the value of your input field by using the super global array $_POST and in your case, you can access the variable in your PHP script using $_POST['one'] (i.e. by the name of the field and not the id). Quote Link to comment Share on other sites More sharing options...
craigafer Posted September 12, 2010 Author Share Posted September 12, 2010 so txt1 is a textfield document.getElementByID("txt1").value = "Hello World"; how can i do this in php? $_POST["txt1"]="Hello World" "?" i really dont know sorry if its wrong xD Quote Link to comment Share on other sites More sharing options...
Hypnos Posted September 12, 2010 Share Posted September 12, 2010 PHP and javascript are not interchangeable. PHP generates pages. Javascript runs after the page is loaded. how can i do this in php? $_POST["txt1"]="Hello World" "?" You have to echo the HTML for the txt1 with hello world in it. <?php $text = "Hello world"; ?> <input type="text" value="<?php echo $text ?>"/> Quote Link to comment Share on other sites More sharing options...
craigafer Posted September 13, 2010 Author Share Posted September 13, 2010 thnx im gonna try it im currently resting for awhile Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.