#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2002
    Posts
    205
    Rep Power
    0

    Question 2 questions about php and javascript...


    Hi i have few questions about php and javascript...

    1) I tried several times to pass a php variable to my javascript variable but i failed. Here is my tests:

    first try:
    PHP Code:
    <?php 
    include ("content_funcs.php");
    // exp: get_content returns a string...
    echo "content[0][\"body\"] = get_content(1, $c_id);";
    ?>
    another try:
    PHP Code:
    <?php 
    include ("content_funcs.php");
    // exp: get_content returns a string...
    $buffer get_content(1$c_id);
    echo 
    "content[0][\"body\"] = $buffer";
    ?>
    After these, no syntax error happens but i came across with a white page...

    2) Is there a way to control if there is a mail adress or not? I don't want to control just syntax of the mail adress , (because people always give a good syntaxed but not working mail adressess so my confirmation mails always come back...) i also want to control if there is a mail and working... Can this be done by my server i mean like mailserver pinging???

    Thanx who reads...
  2. #2
  3. No Profile Picture
    Dissident
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Mar 2003
    Location
    New York
    Posts
    1,671
    Rep Power
    49
    Without seeing the code from content_funcs.php, I don't see how anyone could be expected to provide meaningful input.

    We have no idea if get_content() is a javascript function or a php function. We have no idea if content[0][\"body\"] is supposed to be a php array, a javascript array or just a string to be printed to the screen.

    As far as email addresses, the only way to check if an email address exists is to send an email to that address and have the owner of that address take some action based on your email. (it's a good thing too, otherwise, we'd all get 100 times the spam we get now.)
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2002
    Posts
    205
    Rep Power
    0
    Ok you are right about uninformed question 1 and sorry for that: Let me explain: I call get_content() func from the content_funcs.php and it works properly with echos and prints... This func prints the content from db to the screen and now i want these texts animated with javascript like fading text effects in dynamicdrive and javascriptkit.com... So content[0][\"body\"] is a javascript variable which represents: news 1's body part and then will go to a javascript fader function...
  6. #4
  7. No Profile Picture
    Dissident
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Mar 2003
    Location
    New York
    Posts
    1,671
    Rep Power
    49
    did you try just plain
    PHP Code:
    echo $buffer
    to make sure that you are in fact getting what you are expecting to get?

    Without seeing the javascript that uses content[0]['text'] not much we can do.

    It could be something as simple as you forgot to put the <SCRIPT> tags around the php section where you print out content[0]['body'].
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2002
    Posts
    205
    Rep Power
    0

    Post


    I did by a more simple way. Thanx to http://www.javascriptkit.com/dhtmltu...dingtext.shtml I changed the script a bit and it is working now... Ok then do you know how can i make a delay for the contents i mean is there a function to make a waiting like when fading the first content the other waits for ex in code the func is setTimeout("fadetext()",20); like that how can i make the next content to wait 2 seconds? Is there a thing like: wait(2000); ??? Thanx

    PHP Code:
    <body onLoad="fader()">
    <?php 
    include ("database_connection.inc");
    include (
    "content_funcs.php"); 
    ?>
    <script language="JavaScript1.2">
    hex=255 // Initial color value.

    function fader(){ 
        if(hex>0) 
        { //If color is not black yet
            hex-=11; // increase color darkness
            document.getElementById("sample").style.color="rgb("+hex+","+hex+","+hex+")";
            setTimeout("fadetext()",20); 
        }
        else
            hex=255 //reset hex value
        }

    </script>

    <div id="sample" style="width:100%"><h3><?php get_content(1$c_id); ?></h3></div>
  10. #6
  11. No Profile Picture
    Dissident
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Mar 2003
    Location
    New York
    Posts
    1,671
    Rep Power
    49
    i don't understand you at all. Could you try describing what you want to do using more than 1 sentence. = P
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2002
    Posts
    205
    Rep Power
    0
    Ok then, simply I want to know how can i set an interval between to functions???
  14. #8
  15. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    28
    Rep Power
    0
    in php or in javascript?

    in js it's the setTimeout() function.
    Last edited by slimsam1; June 18th, 2003 at 01:19 PM.
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2002
    Posts
    205
    Rep Power
    0
    how can i do this? is it like: timeout("fader1","fader2",3000); ???
  18. #10
  19. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    28
    Rep Power
    0
    You should probably ask the javascript forum how.

    Sorry, I meant setTimeout, not timeout.

    <script type="text/javascript">
    <!--
    setTimeout("alert('any function here instead of alert.');",30000);
    // -->
    </script>

    http://www.google.com/search?num=100...ipt+settimeout
  20. #11
  21. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2002
    Posts
    205
    Rep Power
    0
    Ok then first i must say i am not an english spoken man so...
    Let me explain what i want to do: i want to execute a javascript function and then put an interval after this function and then execute another function and these two functions are different like fader1 and fader2. I don't want to loop like in setTimeout()...??? Thanx for your patience about the language...

IMN logo majestic logo threadwatch logo seochat tools logo