dbi and javascript

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • john

    dbi and javascript

    I have 2 major issues currently with javascript.

    1. Doesnt anybody do any server side javascript anymore. I cant find
    anything on the net about it. My major issue is with database connections
    and queries. How do I set up a connection and send a quiery. any how-tos,
    links, sample code, advice whatever.

    2. i fave a form that is dynamicly creating elements and I am trying to
    pass it to a server side script. How do I do this. The number of elements
    will be different everytime. 1 field will be the same every time and that
    will be the number of elements I am passing. so the url will look
    something like this

    a.html?number=" + number +"&element0= "+ document.forms[0].elements
    [0].value

    or

    a.html?number=" + number +"&element0= "+ document.forms[0].elements
    [0].value +"&element1= "+ document.forms[0].elements[1].value

    etc.



    3. this.location.r eplace(send); I am trying to use this as a redirect,
    why doesnt it work? I call it when the submit button on the form is hit
    and the form figures out which elements have been chosen. any ideas

  • kaeli

    #2
    Re: dbi and javascript

    In article <Xns9410960496F BFwenjoh26emNOS PAMailp@216.65. 98.9>, wenjoh26
    @emNOSPAMail enlightened us with...[color=blue]
    > I have 2 major issues currently with javascript.
    >
    > 1. Doesnt anybody do any server side javascript anymore. I cant find
    > anything on the net about it. My major issue is with database connections
    > and queries. How do I set up a connection and send a quiery. any how-tos,
    > links, sample code, advice whatever.
    >[/color]

    Sure, but it's most common as JScript with ASP.
    The syntax is a little different, IIRC, from Netscape's server-side
    javascript. Someone correct me if I'm wrong.
    If you're using ASP, search for JScript instead of javascript for links
    (Google).
    [color=blue]
    > 2. i fave a form that is dynamicly creating elements and I am trying to
    > pass it to a server side script. How do I do this.[/color]

    The same way you always do. With GET or POST.

    If you're "passing" it to a server-side script via the URL, simply
    submit using GET instead of POST and you don't have to build a URL.

    If for some odd reason you feel the need to replace, as you imply below,
    loop through the form element array and build the url.
    e = document.myForm Name.elements;
    l = e.length;
    for (i=0; i<l; i++)
    {
    // e[i] is a form element with name and value - do something with
    it
    }
    [color=blue]
    >
    >
    > 3. this.location.r eplace(send); I am trying to use this as a redirect,
    > why doesnt it work? I call it when the submit button on the form is hit
    > and the form figures out which elements have been chosen. any ideas[/color]

    What doesn't it do that you think it should? "it doesnt work" is about
    as descriptive as calling up your mechanic and telling him your car is
    broken.

    -------------------------------------------------
    ~kaeli~
    Jesus saves, Allah protects, and Cthulhu
    thinks you'd make a nice sandwich.


    -------------------------------------------------

    Comment

    • john

      #3
      Re: dbi and javascript

      kaeli <infinite.possi bilities@NOSPAM att.net> wrote in
      news:MPG.19f0c7 8deac5c6c69898b c@nntp.lucent.c om:
      [color=blue]
      > In article <Xns9410960496F BFwenjoh26emNOS PAMailp@216.65. 98.9>,
      > wenjoh26 @emNOSPAMail enlightened us with...[color=green]
      >> I have 2 major issues currently with javascript.
      >>
      >> 1. Doesnt anybody do any server side javascript anymore. I cant find
      >> anything on the net about it. My major issue is with database
      >> connections and queries. How do I set up a connection and send a
      >> quiery. any how-tos, links, sample code, advice whatever.
      >>[/color]
      >
      > Sure, but it's most common as JScript with ASP.
      > The syntax is a little different, IIRC, from Netscape's server-side
      > javascript. Someone correct me if I'm wrong.
      > If you're using ASP, search for JScript instead of javascript for
      > links (Google).[/color]

      Jscript is the exact same thing as javascript except that it is produced
      by microsoft. You know how it goes microsoft is to cheap to licence
      anything so they make there own shitty version (which nobody uses because
      of vb (which is another crappy language)). In then end microsoft realizes
      that its language is no good then pays the licensing fee's. You can do
      javascript with a runat="server" in the script heading and it does run on
      iis. Im not even sure microsoft supports jscript anymore.[color=blue]
      >[color=green]
      >> 2. i fave a form that is dynamicly creating elements and I am trying
      >> to pass it to a server side script. How do I do this.[/color]
      >
      > The same way you always do. With GET or POST.
      >
      > If you're "passing" it to a server-side script via the URL, simply
      > submit using GET instead of POST and you don't have to build a URL.
      >
      > If for some odd reason you feel the need to replace, as you imply
      > below, loop through the form element array and build the url.
      > e = document.myForm Name.elements;
      > l = e.length;
      > for (i=0; i<l; i++)
      > {
      > // e[i] is a form element with name and value - do something with
      > it
      > }
      >[/color]
      the reason I am replacing the url is because I am building a survay which
      has about 300 elements. If the user chooses a radio button, the
      information on that section is needed. If the user does not, then I do
      not. So I was hoping to cut down on bandwidth use by only sending the
      needed information instead of all 300+ elements. Now by what you are
      saying if I recreat the url and pass it, I can get the information by
      reading it like it was a form. So if I do not have a form on my page and
      I pass 7 elements I can get the information with a document.forms
      [0].elements[0].value. am I correct on this?[color=blue][color=green]
      >>
      >>
      >> 3. this.location.r eplace(send); I am trying to use this as a
      >> redirect, why doesnt it work? I call it when the submit button on the
      >> form is hit and the form figures out which elements have been chosen.
      >> any ideas[/color]
      >
      > What doesn't it do that you think it should? "it doesnt work" is about
      > as descriptive as calling up your mechanic and telling him your car is
      > broken.[/color]
      Well basicaly it doesnt do the redirect. I hit submit and it seems to
      pass over this line and just reload the page sending all of the elements.
      Is there issues with submit that makes it have to reload or can I break
      out of the form reload and redirect to where I want to go. Would it be a
      better idea to lose this this.location.r eplace(send); and change the form
      to say document.write( "action=\"" + send +"\"");[color=blue]
      >
      > -------------------------------------------------
      > ~kaeli~
      > Jesus saves, Allah protects, and Cthulhu
      > thinks you'd make a nice sandwich.
      > http://www.ipwebdesign.net/wildAtHeart
      > http://www.ipwebdesign.net/kaelisSpace
      > -------------------------------------------------
      >[/color]

      Comment

      • Lasse Reichstein Nielsen

        #4
        Re: dbi and javascript

        john <wenjoh26@emNOS PAMail@pct.edu> writes:
        [color=blue]
        > Jscript is the exact same thing as javascript except that it is produced
        > by microsoft.[/color]

        Not correct. JScript is an implementation of ECMAScript for browsers,
        just like Javascript
        [color=blue]
        > You know how it goes microsoft is to cheap to licence anything so
        > they make there own shitty version (which nobody uses because of vb
        > (which is another crappy language)).[/color]

        Which is it? Jscript is the same as Javascript (which means that
        plenty of people use it) or nobody uses it?
        [color=blue]
        > In then end microsoft realizes that its language is no good then
        > pays the licensing fee's.[/color]

        There is no licensing fee on Javascript/ECMAScript. Are you thinking
        of Microsoft's Java implementation? Your story sounds more like it.
        [color=blue]
        > You can do javascript with a runat="server" in the script heading
        > and it does run on iis.[/color]

        It runs in ASP, which typically runs on an IIS.
        [color=blue]
        > Im not even sure microsoft supports jscript anymore.[/color]

        They definitly do. The newest version of JScript implements the
        working draft of ECMA 262 version 4, which adds things like classes
        and type declarations to ECMAScript. It is compiled to .net, and can
        therefore be used in ASP.net.
        [color=blue]
        > So if I do not have a form on my page and I pass 7 elements I can
        > get the information with a document.forms [0].elements[0].value. am
        > I correct on this?[/color]

        if "document.f orms[0].elements[0]" is something that is executed on
        the server, then probably. If there are no forms on the client, then
        "document.forms " is empty.
        [color=blue]
        > Well basicaly it doesnt do the redirect. I hit submit and it seems to
        > pass over this line and just reload the page sending all of the elements.[/color]

        Where is "this.location. replace(...)" called? Are you sure "this" refers
        to the global/window object?

        Try adding "return false" to the onsubmit handler (I assume it is called
        from one).
        [color=blue]
        > Is there issues with submit that makes it have to reload or can I break
        > out of the form reload and redirect to where I want to go.[/color]

        Generally, to prevent an action, you return false from the action event
        handler.
        [color=blue]
        > Would it be a better idea to lose this this.location.r eplace(send);
        > and change the form to say document.write( "action=\"" + send +"\"");[/color]

        Most likely not. That would give you an almost empty document containing:
        action=" ...value of send... "

        /L
        --
        Lasse Reichstein Nielsen - lrn@hotpop.com
        Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
        'Faith without judgement merely degrades the spirit divine.'

        Comment

        • kaeli

          #5
          Re: dbi and javascript

          And on the day 10 Oct 2003 21:16:17 -0500, wenjoh26@emNOSP AMail
          enlightened us with <Xns9410E256D9D 70wenjoh26emNOS PAMailp@
          216.65.98.9>...[color=blue]
          >
          > Jscript is the exact same thing as javascript except that it is produced
          > by microsoft. You know how it goes microsoft is to cheap to licence
          > anything so they make there own shitty version (which nobody uses because
          > of vb (which is another crappy language)). In then end microsoft realizes
          > that its language is no good then pays the licensing fee's. You can do
          > javascript with a runat="server" in the script heading and it does run on
          > iis. Im not even sure microsoft supports jscript anymore.[color=green]
          > >[/color][/color]

          No it isn't the same and when you want to find out how to do something
          with it, a search for jscript will bring up a LOT more (useful) results
          than server-side javascript.
          Just because runat=server works in IIS doesn't mean people use it. They
          use language=jscrip t at the top or <script language=jscrip t> and write
          the script in jscript. So, searching for jscript will be much more
          useful for you.
          [color=blue][color=green]
          > >[/color]
          > the reason I am replacing the url is because I am building a survay which
          > has about 300 elements. If the user chooses a radio button, the
          > information on that section is needed. If the user does not, then I do
          > not. So I was hoping to cut down on bandwidth use by only sending the
          > needed information instead of all 300+ elements.[/color]

          It's just text in the URL. I was unaware that affected bandwidth all
          that much. Have you done any testing? I'd love to know the results. My
          apps are all for intranet apps that run on a T1, so it'd be useful for
          me to know in case I ever do an internet application.
          [color=blue]
          > Now by what you are
          > saying if I recreat the url and pass it, I can get the information by
          > reading it like it was a form.[/color]

          SERVER-SIDE.
          If you do it client-side with javascript, you'd need to parse the URL.
          [color=blue]
          > So if I do not have a form on my page and
          > I pass 7 elements I can get the information with a document.forms
          > [0].elements[0].value. am I correct on this?[/color]

          No.
          If you had a radio button called myRadio...
          myVar = Request.Form("m yRadio")

          (That's vbscript - check your language of choice for forms processing on
          the server. It may be the same in jscript.)

          document.forms is client-side AFAIK and is not defined if you don't have
          a form.
          You would build the URL client-side using document.forms, but you must
          have a form.

          [color=blue]
          > Well basicaly it doesnt do the redirect. I hit submit and it seems to
          > pass over this line and just reload the page sending all of the elements.[/color]

          A form with no action defined sends to the same page (so it looks like
          it's refreshing). So...
          <form name="f1" onSubmit="whate ver();return false;">
          (replace the whatever function with yours)
          Return false stops the submission to itself.


          --------------------------------------------------
          ~kaeli~
          Kill one man and you are a murderer. Kill millions
          and you are a conqueror. Kill everyone and you
          are God.


          ------------------------------------------------

          Comment

          Working...