New call-to-action
Results 1 to 5 of 5

Thread: Mixing javascript and Xbasic and other javascript questions ...

  1. #1
    Volunteer Moderator drgarytraub's Avatar
    Real Name
    Dr. Gary Traub
    Join Date
    May 2000
    Location
    Boca Raton, FL
    Posts
    2,794

    Default Mixing javascript and Xbasic and other javascript questions ...

    Where can javascript be used? I know it can be used on pages, but:

    1. Where else can it be used? For example, are there places in components and dialogs where you can insert javascript?

    2. Within a page, can xbasic and javascript share values of variables. For example, can I run a procedure (anything here) with Xbasic and then mix in some javascript to display an alert box or confirm box. For example, would something like this work:

    if tbl.idnumber="231"
    <script text=javascript/text>
    alert("This is idnumber "+tbl.idnumber)
    </script>
    end if

    Gary

  2. #2
    Member Mario Prieto's Avatar
    Real Name
    Mario Prieto
    Join Date
    Apr 2000
    Location
    Las Cruces, NM
    Posts
    364

    Default Re: Mixing javascript and Xbasic and other javascript questions ...

    Variables created with Javascript cannot be seen by XBasic and created by XBasic cannot be seen by Javascript. The only thing they both can see is html code variables like:
    <input type="text" name="custId" value="" >

    XBasic can reference variable custId only after the form or page has been submitted to server.
    and Javascript can reference variable custId only after the page has been loaded or with events (onclick, etc)

    Thing of it as this:
    Javascript is a client(browser)
    XBasic (a5w) is a server programming.
    Once you get around this concept you'll be ready to program web pages.


    hope this helps
    The Mexican

  3. #3
    Volunteer Moderator drgarytraub's Avatar
    Real Name
    Dr. Gary Traub
    Join Date
    May 2000
    Location
    Boca Raton, FL
    Posts
    2,794

    Default Re: Mixing javascript and Xbasic and other javascript questions ...

    Mario,

    Yes, that does help. It is beginning to sink in.

    Let me ask you a basic question then.

    Suppose I have a grid showing 10 records. I have added my own link called "Delete" so the user can delete a row if they wish. This link goes to an a5w page that contains Xbasic where I check to see if the record about to be deleted is used in any other tables, and if so, I prevent the deletion.

    Before, I actually delete the record thouh, I want the user to confirm that this is what they really want to do. On the desktop, this is easily donw with a ui_msg_box, or an xdialog, or even a form. On the web, I can do it within the page, and then display ac dertian part of the page to display whatever message I want. But it would be better if I could display a nice popup, that displays on top of the exisiting page. This is where I thought javascript would be of help. So for example, if the user tries to delete a charge, that has already been billed, I want a message to alert the user that the deletion cannot be done. How would you suggest I do this?

    Gary

  4. #4
    Member Mario Prieto's Avatar
    Real Name
    Mario Prieto
    Join Date
    Apr 2000
    Location
    Las Cruces, NM
    Posts
    364

    Default Re: Mixing javascript and Xbasic and other javascript questions ...

    There are different ways to do this:
    1) When the user clicks on the delete link the delete link calls the same page but adds in the url a delete flag with the user ID for example if the name of the page that you are displaying the records is "clients" then the delete link should look something like this: <a href='clients.a5w?id=24545&delete=yes' >Delete Client </a> have in mind that the id number is created autmatically with xbasic code. Then on the same page you use some code in the <head> section to see if the delete variable exists and if its value is 'yes':
    Code:
    if eval_valid("delete") then
     if delete='yes' then
        ' put some code that calls a function that checks to see if record
        ' is in use and if not delete.
     end if
    end if
    I don't see the reason for checking if somebody is using a record. The only time there would be a conflict it would be when an update and a delete to the same record is sent to th server at the same exact time, we are talking microseconds.

    2) create a transition page that has code that checks and deletes record and then Response.redirects back to the original page. link should look something like this: <a href='deletepage.a5w?id=24545' >Delete Client </a>
    When the page is loaded it checks to see if id exists and then delete:
    dim errormessage as C
    if eval_valid("id") then
    'open table and delete record
    response.redirect("clients.a5w")
    end
    else
    'set some error message in the page
    errormessage="Invalid id or doesn't exists"
    end if

    this is the page:
    <%a5 ? errormesasge %>

    I hope this helps.
    Last edited by Mario Prieto; 07-08-2008 at 01:01 PM.
    The Mexican

  5. #5
    Volunteer Moderator drgarytraub's Avatar
    Real Name
    Dr. Gary Traub
    Join Date
    May 2000
    Location
    Boca Raton, FL
    Posts
    2,794

    Default Re: Mixing javascript and Xbasic and other javascript questions ...

    Mario,

    If I undersatnd what you wrote, that is what I do. I do use the extra page, do processing there, and then link to another page where I can display a message. But what is missing is the ability to display a nice, smaller message ON TOP of the page, like a ui_msg_box or an alert box. I guess we could do something like that with some java script to display the message page in a smaller window. But there are problems with that, like not being able to center the popup window, and the user being able to click outside the popup and then lose where they are.

    Thanks for your thoughts on this. Am I on the right track??

    Gary

Similar Threads

  1. Javascript
    By andymeer@yahoo.co.uk in forum Web Application Server v7
    Replies: 2
    Last Post: 02-03-2007, 03:30 PM
  2. Help in converting more javascript into Xbasic
    By Graham Wickens in forum Alpha Five Version 6
    Replies: 9
    Last Post: 12-14-2005, 11:50 AM
  3. Help to convert some javascript to Xbasic
    By Graham Wickens in forum Alpha Five Version 6
    Replies: 3
    Last Post: 11-23-2005, 04:29 PM
  4. javascript
    By Josh Curtis in forum Web Application Server v6
    Replies: 3
    Last Post: 05-17-2005, 03:50 PM
  5. JavaScript
    By davidv43 in forum Web Application Server v6
    Replies: 2
    Last Post: 08-12-2004, 10:11 AM

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
  •