Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jun 2005
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile isset() with javascript

    im trying to run this code once the variable ADATE is set, why is this not working?

    <?php
    if (isset($_GET['ADATE'])) {
    $result1 = mysql_fetch_array($query1);
    ?>
    <SCRIPT TYPE="TEXT/JAVASCRIPT">
    document.date.c_number.value = <?php echo $result1['C_NUMBER']; ?>
    document.date.date.value = <?php echo $result1['A_DATE']; ?>
    </SCRIPT>
    <?php
    }
    ?>
    You can see it in action here (bottom form)
    http://www.lukesplace.com/Padilla/createreport1.php

    thanks for helping me.

  • #2
    Regular Coder
    Join Date
    Feb 2005
    Location
    West Midlands, UK
    Posts
    623
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well, the data seems to be there, you probably need to input it in quotes though since it seems to be string data. Try:

    document.date.date.value="<?php echo $result1['A_DATE']; ?>";

    Really though that seems to be more of a javascript question if the PHP is doing what it's meant to. You might have more success there.

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well this is what the output of your JS looks like:
    Code:
    <SCRIPT TYPE="TEXT/JAVASCRIPT">
    this.date.c_number.value = 1<br>
    document.date.date.value =   final date<br>
    </SCRIPT>
    The break tags are causing errors, and should the second value be a string? Or is that its name and not its value?
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark


  •  

    Posting Permissions

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