Announcement

Collapse
No announcement yet.

sc_ajax_javascript passing parameter

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • sc_ajax_javascript passing parameter

    HI,

    I have problems with return parameter with the ajax_javascript macro.
    Want a javascript function with return parameter true or false (boolean)

    On the app form, i make a javascript method with a parameter status. Like this

    sc_ajax_javascript("msgboxjs",[test]);


    ---> Msgboxjs is the javascript function and Test the global variable to pass.

    Msboxjs([test])

    if (confirm('Save?')){
    return "Yes";
    }

    ---------------
    How do you pass the parameter.
    Is this with return? or with the parameter name (global) in the header


    regards Marcel

  • #2
    Hi Marcel,
    I just read your post, having to something with passing a value from the database into a javascript button. maybe this will help you or anyone else who needs to do this:

    First, I have tested the variable initialization in both the onApplicationInit or onLoad events in a control type app. The 3 lines of code below will echo out a javascript variable that can be used later , in the javascript button. Note that you need to be careful about the quotes. I had to have the single quotes around the var value. If you have problems, use firebug to debug console to see the error. I caught one when I forgot the single quotes. The var was undefined.



    // get stuff based on the org's own settings in DB
    $theinfo = "saturn1234";
    echo "<script type='text/javascript'> var thejsinfo = '".$theinfo ."';</script>";



    Now you can use the var in your javascript in the button, just like if you had defined it in the script. To test that it is working, try the following as your code in the button:

    alert("thejsinfo has been passed="+thejsinfo);



    Anyway, that works. I was just doing this and did a forum search and no one had answered you, so here it is. Better late than never
    Peace,
    Jamie

    Comment


    • #3
      Originally posted by onmountain View Post
      Hi Marcel,
      I just read your post, having to something with passing a value from the database into a javascript button. maybe this will help you or anyone else who needs to do this:

      First, I have tested the variable initialization in both the onApplicationInit or onLoad events in a control type app. The 3 lines of code below will echo out a javascript variable that can be used later , in the javascript button. Note that you need to be careful about the quotes. I had to have the single quotes around the var value. If you have problems, use firebug to debug console to see the error. I caught one when I forgot the single quotes. The var was undefined.



      // get stuff based on the org's own settings in DB
      $theinfo = "saturn1234";
      echo "<script type='text/javascript'> var thejsinfo = '".$theinfo ."';</script>";



      Now you can use the var in your javascript in the button, just like if you had defined it in the script. To test that it is working, try the following as your code in the button:

      alert("thejsinfo has been passed="+thejsinfo);



      Anyway, that works. I was just doing this and did a forum search and no one had answered you, so here it is. Better late than never
      Peace,
      Jamie

      Hi Jamie,
      An alternative to do backwards? (From javascript to php)

      I use php to javascript option because not know another way to do it. The point is I want to run the php code, send a message to the user to
      'Accept' or 'cancel' and function of the selection of the option, php app execute one form or another grid.

      Can I do this differently?
      thanks

      Comment


      • #4
        Please, don't necropost. Ser the other post about this.
        /Giuseppe

        Professional Scriptcase Services
        Some Customers opinions

        Comment

        Working...
        X