Page 1 of 2 12 LastLast
Results 1 to 15 of 19

Thread: ASP and JavaScript

  1. #1
    Join Date
    Jan 2004
    Melbourne, Australia

    ASP and JavaScript

    A direct relationship between the two is simply non-existant. Both technologies were developed by seperate companies which have relatively nothing to do with each other.

    JavaScript, a product of Netscape, was developed to allow web programmers to write applications which could interact with web browsers. Whilst Active Server Pages, on the other hand, was developed to allow programmers to create data driven websites.
    ASP, as the name implies, is a server-side technology framework (really just a collection of objects, which are interacted with via one of two languages; VBScript or JScript). This fact alone forbids ASP from directly communicating with JavaScript.
    Infact, an ASP script will be completely executed and forgotten about by the time the page is even downloaded and displayed on the users screen.

    When a user requests a page, say 'category.asp', the browser will request the page from the server. Once the page has been located, the source code will be processed on the server and, if necessary, HTML code will be output and displayed to the user. With that said, it should now sound completely illogical to assign a JS variable to an ASP script without first sending the data to the server for processing.

    I am aware of the indirect ways which ASP can influence Javascript. Such as; setting Javascript variables from the server. The following is a simple example:

    dim x 
    x = 2
    response.write("<script>var x = " & x & ";</script>")
    The preceding ASP script simply defines a variable named 'x' and then prints its value to the output. This method actually doesnt show any evidence of ASP and JavaScript communicating.

    Some people will say "But you can use JavaScript to write ASP scripts". This actually isnt true. You can use a spawn of JS call JScript. JScript was also developed by Microsoft and is used for both client side and server side scripting. When using JScript in an ASP application, you would not refer to it as JS, but as ASP, none the less.

    Andrew Buntine.
    Last edited by buntine; 03-10-2005 at 12:22 AM.
    Share on Google+

  2. #2
    Join Date
    Jun 2005
    Hmmm. Quite informative but if someone needs to use server side script why not JSP
    Share on Google+

  3. #3
    Join Date
    Jan 2004
    Melbourne, Australia
    Because JSP is a Sun technology that uses the Java programming language. Java and JavaScript are completely different, too.

    Share on Google+

  4. #4
    Join Date
    Aug 2005
    Wales, UK

    Thanks for this buntine

    This has answered my question I posted today...

    Simple really - just needed a bit of lateral thinking on my part which I didn't quite achieve but, fortunately, you already have...

    Thanks again
    (a, now, very happy developer )
    Share on Google+

  5. #5
    Join Date
    Aug 2005
    Karachi, Pakistan

    Exclamation whats up

    I simply cannot understand, what is the problem. It is just a simple ASP code writing javascript. So why are you trying to make some relation between javascript and asp.
    Share on Google+

  6. #6
    Join Date
    Aug 2005
    jl. Krakatau Ujung No. 100 Medan - Indonesia
    What about asp tag in javascript..how can I combine those..?? I really confuse..please help me...thanks anyway

    example :

    if (window.mm_menu_0829152119_0) return;
    window.mm_menu_0829152119_0 = new Menu("root",139,16,"Verdana",10,"#FFFFFF","#990033","#CC9999","#FFFFFF","left","middle",3,0,1000,-5,7,true,true,true,0,true,true);
    mm_menu_0829152119_0.addMenuItem("Program&nbsp;Kemitraan","location='detailberita.asp?id=<% =rs(0).value%>'";
    Share on Google+

  7. #7
    Join Date
    Jan 2004
    Melbourne, Australia
    Try this:
    mm_menu_0829152119_0.addMenuItem("Program&nbsp;Kemitraan","location='detailberita.asp?id=<%= rs(0).value%>'";
    <% = and <%= will be interpreted differently.

    Share on Google+

  8. #8
    Join Date
    Feb 2006
    Konnichiwa..Erm..I could not understand what the topic here is all about? Care to enlighten me? Btw I'm new to ASP & I would really LOVE to get down to real business here with ASP. *smile* I welcome all opinions & ideas.
    SEX is the price women pay for marriage while MARRIAGE is the price men pay for sex.
    Share on Google+

  9. #9
    Join Date
    Feb 2006
    Stourbridge, UK
    hi there

    I have written a simple website which displays info stored in an access database on our webserver. I use vb script to return the info and display and vbscript again to update the database.

    Am I right in thinking that VB script runs on the server due to IIS? and anything I write in the asp pages that is javascript runs on the client pc?

    If this is the case, I have a javascript routine which is not doing what i want on a website, only when used on a PDA. Is it possible to write the javascript to execute on the server? If this in fact would solve the problem.

    Any guidance would be appreciated


    Steve Chase
    Share on Google+

  10. #10
    Join Date
    Aug 2005
    Karachi, Pakistan

    Nice effort

    Nice effort of giving knowledge to beginnners.
    Share on Google+

  11. #11
    Join Date
    Apr 2006

    I need to pass parameter from javascript function to asp script page

    Might look almost absurd, specially when the theme of thread shows otherwiswe, but I need to pass a few parameters to an asp sub-routine from a javascript (js) function.

    Here is my problem with little bit more information on what I want to do.

    An asp page, when requested, returns an html page that has 2 frames, say Frame A and Frame B, A being on the first half of the html page and B on the second half.

    There are various buttons attached with the frames. Like move up/down, delete, etc.

    I want to write a log file that records action taken by the user. For example, if 'move up' button is clicked in Frame B, the log file has a entry for it with the following information: userName pageName frameName action timestamp.

    testUsr 1 B "moved up" 200604170211
    The movement of the frames (up/down) or deleting, etc has been done as follows:

    Inside the asp file:
    javascript:up(param1, param2..)
    which calls a function 'up' in a xxx.js file. Inside it, I call another asp that does the swapping, or deleting as the case may be.

    I want to call a write sub-routine, an asp file that does the log writing:

    function up(param1, param2..){
           1. code that calls a sub-routine for logging
           2. location.href = "xxx.asp?... to move up/down, etc
    Is it possible to go get my wring done and come back to no 2. ? Some kind of redirection? Generating a new browser page is not acceptable and the logging process cannot take noticeable time because when a 'move up' button is clicked, the frame needs to move up instantly.

    The writing part, an asp sub-routine is complete and works fine, but I have not been able to pass parameters to it.

    Is it going to a smooth landing or am I in for a good ride?

    Thank you for any help/hint.
    Share on Google+

  12. #12
    Join Date
    Apr 2005
    Hastings, Sussex, UK.
    You have two options.

    1) Call the page again passing the variables in the address. This adds an undesirable refresh though.

    2) The preferred method is a little slice of Web 2.0. You can use XMLHttpRequest to call ASP (or any serverside) directly from the JavaScript and use the response to update the page. All this without a refresh. Most browsers will be fine but current Opera has a problem with it.
    Share on Google+

  13. #13
    Join Date
    Sep 2006
    Hi everyone could anyone tell me exactly wt is the discussion going on so that i could help i will try and solve the issue

    Beacuse we have done projects in ASP, ASP.Net and Java/J2ee....
    Share on Google+

  14. #14
    Ubik's Avatar
    Ubik is offline &lt;%= &quot;New Meja Hor&quot; %&gt;
    Join Date
    Nov 2005
    This discussion is for people who haven't grasped that ASP is server side and JavaScript is Client Side.

    Then, it also gets complicated because JavaScript can be run server-side under ASP.

    And, it gets more complicated with AJAX.

    If I have no idea what you are talking about, then I will pretend I know and answer accordingly.

    Thinking about starting a New Thread entitled 'Please Help Me!' ? Read this!
    Share on Google+

  15. #15
    Join Date
    Sep 2006
    I'm happy there's a website such as this here in the net...
    Anyway... Can someone please help me out on my ASP... It's giving me headaches... I always recieve errors such as Data Source name not found or/and no default server specified... Can someone help me please... This is the code I use....

    <% Response.Buffer = true %>
    <body background="C:\Documents and Settings\db2admin\My Documents\JTR - HTML - Project 01\Pics\snowflake.bmp">
    dim data_source,insertpatient,insertkin,insertlifestyle,insertbcomplaint,inserti_mcomplaint,conn,rs
    dim opid,firstname,middlename,lastname,sex,dob,current_address,permanent_address,tel_home,mobile,tel_wor k,pager,fax,email
    dim kin_name,relationship,kin_address,kin_telhome,kin_mobile,kin_telwork,kin_pager,kin_fax,kin_email
    dim maritalstatus,no_of_dependents,height,weight,blood_type
    dim occupation,annualincome
    dim vegetarian,smoker,avgcig,consumealc,nodrinks,stimulant2,stimulants,consumect,consumefd,meals,food
    dim statement,histreat,history,phy_hospital
    dim diabetic,diadesc,hypertansive,hypdesc,cardiac,cardesc,respiratory,respdesc,digestive,digdesc,orthope dic,ortdesc,muscular,musdesc,neuro,neudesc,allergies,al_desc,surgeries,surgdesc

    opid = Request.Form ("opid")
    firstname = Request.Form ("firstname")
    middlename = Request.Form ("middlename")
    lastname = Request.Form ("lastname")
    sex = Request.Form ("sex")
    dob = CDate (Request.Form ("birthmonth") & "/" & Request.Form ("birthdate") & "/" & Request.Form ("birthyear"))
    current_address = Request.Form ("current_address")
    permanent_address = Request.Form ("permanent_address")
    tel_home = Request.Form ("tel_home")
    mobile = Request.Form ("mobile")
    tel_work = Request.Form ("tel_work")
    pager = Request.Form ("pager")
    fax = Request.Form ("fax")
    email = Request.Form ("email")

    kin_name = Request.Form ("kin_name")
    relationship = Request.Form ("relationship")
    kin_address = Request.Form ("kin_address")
    kin_telhome = Request.Form ("kin_telhome")
    kin_mobile = Request.Form ("kin_mobile")
    kin_telwork = Request.Form ("kin_telwork")
    kin_pager = Request.Form ("kin_pager")
    kin_fax = Request.Form ("kin_fax")
    kin_email = Request.Form ("kin_email")

    maritalstatus = Request.Form ("maritalstatus")
    no_of_dependents = Request.Form ("no_of_depentents")
    height = Request.Form ("height")
    weight = Request.Form ("weight")
    blood_type = Request.Form ("blood_type")

    occupation = Request.Form ("occupation")
    annualincome = Request.Form ("annualincome")

    vegetarian = Request.Form ("vegetarian")
    smoker = Request.Form ("smoker")
    avgcig = Request.Form ("avgcig")
    consumealc = Request.Form ("consumealc")
    nodrinks = Request.Form ("nodrinks")
    stimulants = Request.Form ("stimulants")
    stimulant2 = Request.Form ("stimulant2")
    consumect = Request.Form ("consumect")
    consumefd = Request.Form ("consumefd")
    meals = Request.Form ("meals")
    food = Request.Form ("food")

    statement = Request.Form ("statement")
    history = Request.Form ("history")
    histreat = Request.Form ("histreat")
    phy_hospital = Request.Form ("phy_hospital")

    diabetic = Request.Form ("diabetic")
    diadesc = Request.Form ("diadesc")
    hypertensive = Request.Form ("hypertansive")
    hypdesc = Request.Form ("hypdesc")
    cardiac = Request.Form ("cardiac")
    cardesc = Request.Form ("cardesc")
    respiratory = Request.Form ("respiratory")
    respdesc = Request.Form ("respdesc")
    digestive = Request.Form ("digestive")
    digdesc = Request.Form ("digdesc")
    orthopedic = Request.Form ("orthopedic")
    ortdesc = Request.Form ("ortdesc")
    muscular = Request.Form ("muscular")
    muscdesc = Request.Form ("muscdesc")
    neuro = Request.Form ("neuro")
    neudesc = Request.Form ("neudesc")
    allegries = Request.Form ("allergies")
    al_desc = Request.Form ("al_desc")
    surgeries = Request.Form ("surgeries")
    surgdesc = Request.Form ("surgdesc")

    insertpatient = "INSERT INTO add_patient (opid,firstname,middlename,lastname,sex,dob,current_address,permanent_address,tel_work,tel_home,mobi le,pager,fax,email,maritalstatus,no_of,dependents,height,weight,blood_type,occupation,annualincome) VALUES ('" & opid & "','" & firstname & "','" & middlename & "','" & lastname & "','" & sex & "','" & dob & "','" & current_address & "','" & permanent_address & "','" & tel_work & "','" & tel_home & "','" & mobile & "','" & pager & "','" & fax & "','" & email & "','" & maritalstatus & "','" & no_of_dependents & "','" & height & "','" & weight & "','" & blood_type & "','" & occupation & "','" & annualincome & "')"
    insertkin = "INSERT INTO add_nextofkin (opid,kin_name,relationship,kin_address,kin_telhome,kin,mobile,kin_telwork,kin_pager,kin_fax,kin_ema il) VALUES ('" & opid & "','" & kin_name & "','" & relationship & "','" & kin_address & "','" & kin_telhome & "','" & kin_mobile & "','" & kin_telwork & "','" & kin_pager & "','" & kin_fax & "','" & kin_email & "')"
    insertlifestyle = "INSERT INTO lifestyle (opid,vegetarian,smoker,avgcig,consumealc,nodrinks,stimulants,stimulant2,consumect,consumefd,meals,f ood) VALUES ( '" & opid & "','" & vegetarian & "','" & smoker & "','" & avgcig & "','" & consumealc & "','" & nodrinks & "','" & stimulants & "','" & stimulant2 & "','" & consumect & "','" & consumefd & "','" & meals & "','" & food & "')"
    insertbcomplaint = "INSERT INTO bcomplaint (opid,statement,history,histreat,phy_hospital) VALUES ('" & opid & "','" & statement & "','" & history & "','" & histreat & "','" & phy_hospital & "')"
    inserti_mcomplaint = "INSERT INTO i_mcomplaint (opid,diabetic,diadesc,hypertensive,hypdesc,cardiac,cardesc,respiratory,respdesc,digestive,digdesc,o rthopedic,ortdesc,muscular,muscdesc,neuro,neudesc,allergic,al_desc,surgeries,surgdesc) VALUES ('" & opid & "','" & diabetic & "','" & diadesc & "','" & hypertensive & "','" & hypdesc & "','" & cardiac & "','" & cardesc & "','" & respiratory & "','" & respdesc & "','" & digestive & "','" & digdesc & "','" & orthopedic & "','" & ortdesc & "','" & muscular & "','" & muscdesc & "','" & neuro & "','" & neudesc & "','" & allergic & "'.'" & al_desc & ",'" & surgeries & "','" & surgdesc & "')"

    data_source = "DSN = projectvirgo"

    Set conn = Server.CreateObject("ADODB.Connection")
    Set rs = Server.CreateObject("ADODB.Connection")
    conn.Open data_source
    conn.Execute insertpatient
    conn.Execute insertkin
    conn.Execute insertlifestyle
    conn.Execute insertbcomplaint
    conn.Execute inserti_mcomplaint

    Set conn = nothing


    <h2><FONT color=BLUE>Patient '" & opid & "', Mr./Ms./Mrs. '" & lastname & "', has been added to the database. Thank you... </FONT></h2>
    <FONT color=GOLD>To view records click</FONT> <a href="view.asp"><h3><FONT color=SILVER>here</FONT></h3></a>

    Please help me out... Thanks....
    Share on Google+

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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