Page 1 of 2 12 LastLast
Results 1 to 10 of 15
  1. #1

    Default Help! PHP and JAVASCRIPT


    tabang..... naa ko problem... mao unta ni ako gusto mahitabo... peru d man pwede...

    <script type="text/javascript">
    function sample()
    {
    var result = confirm('Would you like to continue Mr. <?php echo $name; ?>');

    if( result == true )
    {
    /***[gusto unta ko mu invoke/gamit ug PHP function from a class diri dapita]***/
    <?php $sampleclass->display(); ?> // dili man ni pwede... unsaon mani?
    document.writeln("success");
    }
    }
    </script>
    .
    .
    .
    <input type = "image" src="images/confirm.png" name="button" onClick = sample()>
    naa ba ni lain way aron mabuhat ni nku? tabang pls.....

  2. #2
    bro,

    unsa may buhaton ani nga function ? $sampleclass->display()
    ang return value ana ang gusto nimo ipa display?

  3. #3
    ang problema nku ani bro kay dili kung unsay buhaton sa function.... kundi pag invoke sa function....
    kay dili mu run ang PHP na function pag invoke nku sulud sa javascript...

  4. #4
    mind to post the error bro if naa ngano ka ingon ka nga dili mo work?
    and have you tried checking your php log if there are any errors?
    just want to help, but needs more info

  5. #5
    na instantiate na nimo ang $sampleclass na object?

  6. #6
    naa na ko'y improvements mga bro....
    ako ra gbalhin ang script tag sa ubos sa mga PHP statements nku...

    <?php
    $begin = new sampleclass(); //instantiating class
    .
    // codes here
    .
    ?>
    <input type="image" src="https://www.istorya.net/forums/images/confirm.png" name="confirmButton" onClick= test()></input>
    <script type="text/javascript">
    function test()
    {
    var result=confirm('Are you sure to continue Mr.<?php echo $name; ?>');
    if( result == true)
    {
    <?php $begin->save(); ?> // save() do insert query to DB
    }
    </script>
    ang problem nsad ani kay mu diretsu xa ug buhat sa statement na $begin-save() bsag wala pa nku ma click ang confirmButton which has an onClick attribute... nkahibaw ko na ni run ug una ang statement na $begin-save() kay nka insert man xa sa ako DB...

    ang gusto ra jd unta nku ani kay:

    -mugawas ang confirm window if gusto ba niya e save or not
    -if yes, do query via $begin->save()

    so far wala pa nku nakuha ang gusto nku makuha.... tabang.... nkasabot mo sa ako prob?
    possible ba ni?

  7. #7
    You lack a closing curly brace. I don't think na pwede na sa javascript? I'm a beginner pa man sad.

    Here is how I would do it:

    Code:
    <html>
    <head>
      <title>Mic Test</title>
    </head>
    <body>
    <?php
    $sample = new Sample();
    
    if(!$_POST) {
      echo 'Do you want to continue ' . $name . '?'; 
      
      ?>
      <form method="post">
      <input type="checkbox" value="1" name="answer" />
      <input type="submit" name="Submit" />
    
    <?php
    }
    else {
      if(isset($_POST['answer']) && $_POST['answer']) {
        $sample->save();
      } else {
        echo 'Okay...';
      }
    }
    ?>
    </body>
    </html>

  8. #8
    http is stateless. you have to get used to not treating a website or page like a desktop app. once you have served an html page you "lose" connection to the PHP objects. these days there's ajax but that's another story.

    Code:
    <script>
    function test() {
        var msg = '...';
        if (window.confirm(msg))
            window.location.href = '/url/to/db/save';
    }
    </script>

  9. #9
    keep in mind that php is server side while javascript is client side.

    so basically php runs, even before the page is returned from a request.

  10. #10
    Quote Originally Posted by tynum View Post
    tabang..... naa ko problem... mao unta ni ako gusto mahitabo... peru d man pwede...



    naa ba ni lain way aron mabuhat ni nku? tabang pls.....
    maybe you can try this one.

    <html>
    <head>

    <?php
    //just a sample functions
    function sampSAVEfunc(){

    echo "document.writeln('Save Code Exceuted<br>')";

    }

    ?>

    <script type="text/javascript">

    function checkentry(){
    <?php $name='edvincent'; ?>

    var res = confirm('Would you like to continue Mr. <?php echo $name; ?>');
    return res;

    }

    <?php if($_POST['buttontext']){ sampSAVEfunc(); ?>

    document.writeln("success");

    <?php } ?>



    </script>
    </head>
    <BODY>


    <form name="frm" method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
    <input type = "submit" name="buttontext" value="Click here" onclick="var stat=checkentry();return stat;">
    </form>


    </BODY>
    </html>

  11.    Advertisement

Page 1 of 2 12 LastLast

Similar Threads

 
  1. Replies: 6
    Last Post: 10-12-2012, 11:35 AM
  2. PHP and MSSQL Help
    By bolivar1985 in forum Programming
    Replies: 3
    Last Post: 10-22-2009, 03:42 PM
  3. could anyone help me with php and javascripts
    By isaac42 in forum Programming
    Replies: 6
    Last Post: 05-07-2009, 02:24 PM
  4. Independent contractor info needed---php and mysql
    By BayouPinoy in forum Networking & Internet
    Replies: 0
    Last Post: 03-17-2006, 10:45 PM
  5. HELP: Type and MaxSize of HD (Asus P2B98-XV and Intel CA810)
    By rocknolds in forum Computer Hardware
    Replies: 4
    Last Post: 11-15-2005, 04:04 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top