Is it Possible to get values from java to php???????

Discussion in 'PHP' started by greatthings, Nov 22, 2011.

  1. #1
    Is it Possible to get values from java to php???????

    or How can i get the value of a radio button instantly without redirecting or submitting??
    when the user clicked on a radio button, php gets the radio buttons correponding value and display it. is it possible??

    huhu i've been working for this all night, i've got no sleep TT_TT can someone help me pls???

    thanks in advanz :(((((
     
    greatthings, Nov 22, 2011 IP
  2. mfscripts

    mfscripts Banned

    Messages:
    319
    Likes Received:
    4
    Best Answers:
    8
    Trophy Points:
    90
    Digital Goods:
    3
    #2
    I assume this relates to your other post? :)

    PHP is server side and Javascript is client side. So by the time the browser renders all the html, javascript etc, it's done all the serverside processing within PHP. Hence you can not use Javascript to talk to PHP without reloading the page or using Ajax to prompt another request to the server.
     
    mfscripts, Nov 23, 2011 IP
  3. Alex Roxon

    Alex Roxon Active Member

    Messages:
    424
    Likes Received:
    11
    Best Answers:
    7
    Trophy Points:
    80
    #3
    If you want to use PHP, like mfscripts said, you'll have to use ajax. However, for something as simple as displaying the value of the radio button, you can just use Javascript anyway.

     
    Alex Roxon, Nov 23, 2011 IP
  4. ketting00

    ketting00 Well-Known Member

    Messages:
    782
    Likes Received:
    28
    Best Answers:
    3
    Trophy Points:
    128
    #4
    I've tried to do this too. I've stumbled upon the solution once, but I cannot find it again. They use javascript and ajax. If you were lucky, you might be able to find it.
     
    ketting00, Nov 23, 2011 IP
  5. greatthings

    greatthings Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    ohh :(

    thanks guyz, :) i think it is really impossible to do that :((

    i have a pop-up from which when the radio button is clicked
    and the "validate this client" button is clicked the pop-up will appear
    --i was hoping that the pop-up will be able to get the value of the clicked radio button


    i guess this is really impossible :(((
     
    greatthings, Nov 24, 2011 IP
  6. alltexaspoker

    alltexaspoker Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Well, I assume you're talking about JavaScript, in that case, yea, it is possible:
    using jQuery, you can achieve this easily, for example:

    $.post("mypage.php", {radio1: "val"}, function(data){
    $("#response").html(data);
    });

    What this does, for example, is to make an HTTP request, using POST method, with the query string of ?radio1=val, and return the response back, using a callback function.

    If you want to do this via Java (eg. the OOP Language), you'll need to go the same route of using an HTTP Request, but it's a bit more complex, and you can use the appropriate libraries, documentation is avaible, I believe in oracle.
     
    alltexaspoker, Nov 24, 2011 IP
  7. greatthings

    greatthings Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    thnx ill give it a try :)

    hmmmm... is there a way to refresh a php page, by clicking a popup window button?
    it should refresh before the pop up window appears
     
    greatthings, Nov 24, 2011 IP
  8. NetStar

    NetStar Notable Member

    Messages:
    2,471
    Likes Received:
    541
    Best Answers:
    21
    Trophy Points:
    245
    #8
    Just to save you a headache down the road... JavaScript should be referred to as JavaScript NOT Java. Java is a programming language and should NOT be confused with the client side scripting language JavaScript.
     
    NetStar, Nov 27, 2011 IP
  9. Shiplu

    Shiplu Peon

    Messages:
    42
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    From Javascript, its not possible.
    But you mentioned Java. :p Its certainly possible in Java. :D
     
    Shiplu, Nov 28, 2011 IP
  10. Jesse12

    Jesse12 Member

    Messages:
    360
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    28
    #10
    hi

    this is possible you can try with this.

    <form name="test">

    <input type="radio" id="chk" name="chk" value="set" onClick="setValueInDiv(this);"> to check

    <div id="setHTML">

    </div>

    </form>



    <script>

    function setValueInDiv(obj){

    if(doucment.test.chk.checked){

    document.getElementById('setHTML').innerHTML=doucment.test.chk.value;

    return true;

    }else{

    document.getElementById('setHTML').innerHTML='please select the ration button';

    return false;

    }

    }

    </script>
     
    Jesse12, Dec 1, 2011 IP
  11. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #11
    There might be, if there were such a thing as a PHP page, but there isn't. PHP is used to generate a page that's HTML, Javascript and CSS. A page, not two pages at once (which is what you're asking about).
     
    Rukbat, Dec 1, 2011 IP