SitePoint Sponsor

User Tag List

Results 1 to 19 of 19
  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,729
    Mentioned
    104 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,729
    Mentioned
    104 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,729
    Mentioned
    104 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
    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

  8. #8
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 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

  9. #9
    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>

  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
    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..

  11. #11
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 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

  12. #12
    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....

  13. #13
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by onick View Post
    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....
    Show us what you're doing (a live web page is very useful) and we'll show you what you're doing wrong how to get it working.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  14. #14
    SitePoint Member
    Join Date
    May 2011
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by paul_wilkins View Post
    Show us what you're doing (a live web page is very useful) and we'll show you what you're doing wrong how to get it working.
    Free Job Post, All uk Job sites here, more choice at uwantvgot

    go there.. write something on Enter keyword .. u can leave location field...


    select REED .. the search .....

    once u got the result... u can see details .. click on that thats what i want..

    once some one click on details it should be show the details..

  15. #15
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by onick View Post
    Free Job Post, All uk Job sites here, more choice at uwantvgot

    go there.. write something on Enter keyword .. u can leave location field...


    select REED .. the search .....

    once u got the result... u can see details .. click on that thats what i want..

    once some one click on details it should be show the details..
    There are currently some other scripting problems on the results page too.
    In Internet Explorer's Internet Options page, go to the Advanced tab and turn on "Display a notification about every script error"

    That will help you to find major problems, so that you can then fix them.

    With many other web browsers, you can use Ctrl-Shift-J to show errors.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  16. #16
    SitePoint Member
    Join Date
    May 2011
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by paul_wilkins View Post
    There are currently some other scripting problems on the results page too.
    In Internet Explorer's Internet Options page, go to the Advanced tab and turn on "Display a notification about every script error"

    That will help you to find major problems, so that you can then fix them.

    With many other web browsers, you can use Ctrl-Shift-J to show errors.

    Can you please have a look now and let me know how to do that ?

  17. #17
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by onick View Post
    Can you please have a look now and let me know how to do that ?
    Here's how you do it.

    In Internet Explorer's Internet Options page, go to the Advanced tab and turn on "Display a notification about every script error"
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  18. #18
    SitePoint Member
    Join Date
    May 2011
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by paul_wilkins View Post
    Here's how you do it.

    In Internet Explorer's Internet Options page, go to the Advanced tab and turn on "Display a notification about every script error"
    hi

    Sorry But I am not talking about the error display.... There is no more error ..

    I am talking about.. how can i pass value when i click on that Details Button ....

  19. #19
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by onick View Post
    hi

    Sorry But I am not talking about the error display.... There is no more error ..

    I am talking about.. how can i pass value when i click on that Details Button ....
    you can put the sample code provided earlier in to separate function and call it from the fireMyPopup function
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


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
  •