SitePoint Sponsor

User Tag List

Results 1 to 19 of 19

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    May 2011
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need help to java script passing value

    Can any of you help me to find the soluation please . I have a problem to passing value from java script to php.. here is my code ..


    /**************** PART 1***************************/

    <input type='submit' onClick='MyPopup($tt)' value=' Details '>

    This is my part 1 where I am calling a javascript function and passing a value. I want This value on my PART 3

    /*************** PART2******************/

    <script type="text/javascript" language="javascript">

    /****this function is for popup my <div> *****/

    function MyPopup(tt) {
    setOpacity( 0 );
    document.getElementById("styled_popup").style.display = "block";
    fadeInMyPopup();
    }

    /***** this function is for fade my popup window ********/
    function fadeInMyPopup() {
    for( var i = 0 ; i <= 100 ; i++ )
    setTimeout( 'setOpacity(' + (i / 10) + ')' , 8 * i );
    }
    </script>

    /*************** PART 3*******************/
    Abc.php

    <div id='styled_popup' name='styled_popup' style='width:600px; display:none; position: absolute; top: 150px; left: 50px; zoom: 1'>

    ////////////////////////Want my value here///////////////////////////

    </div>

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,527
    Mentioned
    84 Post(s)
    Tagged
    4 Thread(s)
    Why can you not make use of that $tt value in the third part?
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Member
    Join Date
    May 2011
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi, thanks for your replay.. ya thats i want to do , how i can use that on third part..

  4. #4
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,527
    Mentioned
    84 Post(s)
    Tagged
    4 Thread(s)
    How is Abc.php related to the previous lot?

    Is Abc.php being included? Is a form submitssion taking the person to Abc.php? Is Abc.php accessed by clicking a link? Or is something else happening there.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  5. #5
    SitePoint Member
    Join Date
    May 2011
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi
    basically, all parts are in abc.php

    /**************** PART 1***************************/

    for ($tt=0;$tt<=10; $tt++)
    {
    <input type='submit' onClick='MyPopup($tt)' value=' Details '>
    }

    here on onclick elements is calling MyPopup function...

    this function is popping up the part 3 <div>....

    and I need that $tt value into the <div>



    /*************** PART2******************/

    <script type="text/javascript" language="javascript">

    /****this function is for popup my <div> *****/

    function MyPopup(tt) {
    setOpacity( 0 );
    document.getElementById("styled_popup").style.display = "block";
    fadeInMyPopup();
    }

    /***** this function is for fade my popup window ********/
    function fadeInMyPopup() {
    for( var i = 0 ; i <= 100 ; i++ )
    setTimeout( 'setOpacity(' + (i / 10) + ')' , 8 * i );
    }
    </script>

    /*************** PART 3*******************/
    Abc.php

    <div id='styled_popup' name='styled_popup' style='width:600px; display:none; position: absolute; top: 150px; left: 50px; zoom: 1'>

    ////////////////////////Want my value here///////////////////////////

  6. #6
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,527
    Mentioned
    84 Post(s)
    Tagged
    4 Thread(s)
    If the $tt variable is declared in PHP in part 1, it should automatically be available at all other parts of the PHP code after that.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  7. #7
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,527
    Mentioned
    84 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by paul_wilkins View Post
    If the $tt variable is declared in PHP in part 1, it should automatically be available at all other parts of the PHP code after that.
    Let's get some more details about what you want then.

    Well in that case, you can have the javascript replace the contents of the styled_popup div.

    From within the function with the tt variable:

    Code javascript:
    var text = document.createTextNode(tt),
        div = document.getElementById('styled_popup');
     
    while (div.hasChildNodes()) {
        div.removeChild(div.firstChild);
    }
     
    div.appendChild(text);
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  8. #8
    SitePoint Member
    Join Date
    May 2011
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by paul_wilkins View Post
    Let's get some more details about what you want then.

    Well in that case, you can have the javascript replace the contents of the styled_popup div.

    From within the function with the tt variable:

    Code javascript:
    var text = document.createTextNode(tt),
        div = document.getElementById('styled_popup');
     
    while (div.hasChildNodes()) {
        div.removeChild(div.firstChild);
    }
     
    div.appendChild(text);


    Sorry ! but i dont get you properly...

    what should i need to replace..

  9. #9
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,527
    Mentioned
    84 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by onick View Post
    Sorry ! but i dont get you properly...

    what should i need to replace..
    As an example of usage, you could put it in a separate function and call it from the MyPopup function.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  10. #10
    SitePoint Member
    Join Date
    May 2011
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by paul_wilkins View Post
    As an example of usage, you could put it in a separate function and call it from the MyPopup function.

    Its not working....

    Just want to let you know.. I can have $tt value on MyPopup function()..

    What I need .. Just send data from MyPopup function() to my Div element....

  11. #11
    SitePoint Member
    Join Date
    May 2011
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    but its not constant.. $tt is changing by for loop

  12. #12
    SitePoint Member
    Join Date
    May 2011
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <?

    $tt=0;
    for ($row = 0; $row < 10; $row++)
    {

    $i=($row&1) ? "1" : "0"; ///CHECK No ODD OR EVEn
    if($i=="1") { $color="#EDF7CA"; }
    else if($i=="0") { $color="#EEF8B8"; }
    echo "<tr class='employ' bgcolor='".$color."'>";
    $reed=keydatas_reed($keydata,$location);
    for ($col = 0; $col < 4; $col++)
    {
    if($col!=3){ echo "<td class='employ'>".$reed[$col][$row]."</td>"; }
    else if($col==3)
    {
    echo "<td class='employ'>".$tt."<input type='submit' id='tt' name='tt' onClick='fireMyPopup($tt)' value=' Details '></td>";

    }
    }
    $tt=$tt+1;
    echo "</tr>";
    }
    ?>


    Part 3



    <div id='styled_popup' name='styled_popup' style='width:600px; display:none; position: absolute; top: 150px; left: 50px; zoom: 1'>
    [COLOR="rgb(139, 0, 0)"]<? /* I want to display here different value on different time... depending on $tt value */?>[/COLOR]
    </div>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •