sending variables via cgi form?

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

    sending variables via cgi form?

    Hello,

    I have been able to create a slider using Javascript code from the web
    but would like to send the slider values which are saved in an array
    to myself using email and the CGI/form approach.

    I'm not clear how to get the these array values into the form ..

    Hints/ideas please!

    Cheers

    Geoff
  • Peroli

    #2
    Re: sending variables via cgi form?

    Hi,
    Your question is not clear. Please post your code along with the
    question which would be easier to understand your problem.

    Anyways, try using XMLHTTP or XMLRequest to post the values to the
    server.

    - Peroli Sivaprakasam

    Comment

    • Geoff Cox

      #3
      Re: sending variables via cgi form?

      On 1 Sep 2005 02:20:42 -0700, "Peroli" <peroli@gmail.c om> wrote:
      [color=blue]
      >Hi,
      > Your question is not clear. Please post your code along with the
      >question which would be easier to understand your problem.[/color]


      Peroli,

      Thanks for your reply. At the moment the code below puts the slider
      value into

      <SPAN ID="Slider1Valu eText"></SPAN>

      I would like to be able to put that value into a form so that the
      value could be sent to me via email using formmail.cgi.

      Cheers

      Geoff


      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

      <html>
      <HEAD>
      <SCRIPT
      SRC="http://www.micro-active.com/slider/christiaan/slider.js"></SCRIPT>
      <SCRIPT>

      var mySlider1 = new Slider( "Slider1" );

      mySlider1.leftV alue = 0;
      mySlider1.right Value = 10;
      mySlider1.defau ltValue = 0;

      mySlider1.offse tX = 1;
      mySlider1.offse tY = 1;
      mySlider1.maxSl ide = 258;

      mySlider1.onmou seover = "self.status='T ry me!'";
      mySlider1.onmou sedown = "self.status='Y ou start at
      '+this.getValue (0)";
      mySlider1.onmou seup = "self.status='Y ou end at '+this.getValue (0)";
      mySlider1.oncha nge = "self.status='T he current value is
      '+this.getValue (0)";
      mySlider1.oncli ck = "this.setValue( this.defaultVal ue)";

      mySlider1.oncha nge =
      "document.getEl ementById('Slid er1ValueText'). innerHTML =
      ''+this.getValu e(0)"

      </SCRIPT>


      </HEAD>

      <BODY onLoad="mySlide r1.placeSlider( )">

      <TABLE>
      <TR>
      <TD COLSPAN="3">
      <IMG SRC="sliderbg.g if" NAME="Slider1Ra ilImg" ID="Slider1Rail Img">
      <TR>
      <TD ALIGN="left"> 0
      <TD ALIGN="center"> Slider 1
      <TD ALIGN="right"> 10
      </TABLE>

      <SPAN ID="Slider1Valu eText"></SPAN>

      <SCRIPT>

      mySlider1.write Slider();

      </SCRIPT>


      </body>
      </html>









      [color=blue]
      >
      >Anyways, try using XMLHTTP or XMLRequest to post the values to the
      >server.
      >
      >- Peroli Sivaprakasam[/color]

      Comment

      • Peroli

        #4
        Re: sending variables via cgi form?

        Hi Geoff,
        I have edited your script below. Please download the prototype.js
        that i have included.
        1. Update the url of the CGI script in function saveIt().
        2. In the CGI Script, find the slider value in "SliderVal" parameter.

        Test if it works.... It should.

        - Peroli Sivaprakasam
        _______________ _______________ _____________
        [UNTESTED]

        <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

        <html>
        <HEAD>
        <SCRIPT
        SRC="http://www.micro-active.com/slider/christiaan/slider.js"></SCRIPT>
        <SCRIPT
        SRC="http://prototype.conio .net/dist/prototype-1.3.1.js"></SCRIPT>
        <SCRIPT>

        var mySlider1 = new Slider( "Slider1" );

        mySlider1.leftV alue = 0;
        mySlider1.right Value = 10;
        mySlider1.defau ltValue = 0;

        mySlider1.offse tX = 1;
        mySlider1.offse tY = 1;
        mySlider1.maxSl ide = 258;

        mySlider1.onmou seover = "self.status='T ry me!'";
        mySlider1.onmou sedown = "self.status='Y ou start
        at'+this.getVal ue(0)";
        mySlider1.onmou seup = "self.status='Y ou end at '+this.getValue (0)";
        mySlider1.oncha nge = "self.status='T he current value
        is'+this.getVal ue(0)";
        mySlider1.oncli ck = "this.setValue( this.defaultVal ue)";

        mySlider1.oncha nge
        ="document.getE lementById('Sli der1ValueText') .innerHTML
        =''+this.getVal ue(0)";
        //---------------------------------------------------------------------
        function saveIt()
        {
        var url = 'http://yourserver/sendMail.cgi';
        var pars =
        'sliderVal='+do cument.getEleme ntById('Slider1 ValueText').inn erHTML;
        var myAjax = new Ajax.Updater('S tatus', url, {method: 'get',
        parameters: pars});
        }
        //---------------------------------------------------------------------
        </SCRIPT>

        </HEAD>

        <BODY onLoad="mySlide r1.placeSlider( )">

        <TABLE>
        <TR>
        <TD COLSPAN="3">
        <IMG
        SRC="http://www.micro-active.com/slider/christiaan/sliderbg.gif"
        NAME="Slider1Ra ilImg" ID="Slider1Rail Img">
        <TR>
        <TD ALIGN="left"> 0
        <TD ALIGN="center"> Slider 1
        <TD ALIGN="right"> 10
        </TABLE>
        <input type="button" value="save slider value" onclick="saveIt ()" />
        <SPAN ID="Slider1Valu eText"></SPAN>
        <SPAN ID="Status"></SPAN>

        <SCRIPT>

        mySlider1.write Slider();

        </SCRIPT>

        </body>
        </html>

        Comment

        • Geoff Cox

          #5
          Re: sending variables via cgi form?

          On 1 Sep 2005 04:27:39 -0700, "Peroli" <peroli@gmail.c om> wrote:
          [color=blue]
          >Hi Geoff,
          > I have edited your script below. Please download the prototype.js
          >that i have included.
          >1. Update the url of the CGI script in function saveIt().
          >2. In the CGI Script, find the slider value in "SliderVal" parameter.
          >
          >Test if it works.... It should.[/color]

          Peroli,

          It works fine - many thanks! Will now try and work out how you did
          it!! May get back to you...

          Cheers

          Geoff






          [color=blue]
          >
          >- Peroli Sivaprakasam
          >______________ _______________ ______________
          >[UNTESTED]
          >
          ><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
          >
          ><html>
          ><HEAD>
          ><SCRIPT
          >SRC="http://www.micro-active.com/slider/christiaan/slider.js"></SCRIPT>
          ><SCRIPT
          >SRC="http://prototype.conio .net/dist/prototype-1.3.1.js"></SCRIPT>
          ><SCRIPT>
          >
          > var mySlider1 = new Slider( "Slider1" );
          >
          > mySlider1.leftV alue = 0;
          > mySlider1.right Value = 10;
          > mySlider1.defau ltValue = 0;
          >
          > mySlider1.offse tX = 1;
          > mySlider1.offse tY = 1;
          > mySlider1.maxSl ide = 258;
          >
          > mySlider1.onmou seover = "self.status='T ry me!'";
          > mySlider1.onmou sedown = "self.status='Y ou start
          >at'+this.getVa lue(0)";
          > mySlider1.onmou seup = "self.status='Y ou end at '+this.getValue (0)";
          > mySlider1.oncha nge = "self.status='T he current value
          >is'+this.getVa lue(0)";
          > mySlider1.oncli ck = "this.setValue( this.defaultVal ue)";
          >
          > mySlider1.oncha nge
          >="document.get ElementById('Sl ider1ValueText' ).innerHTML
          >=''+this.getVa lue(0)";
          >//---------------------------------------------------------------------
          > function saveIt()
          > {
          > var url = 'http://yourserver/sendMail.cgi';
          > var pars =
          >'sliderVal='+d ocument.getElem entById('Slider 1ValueText').in nerHTML;
          > var myAjax = new Ajax.Updater('S tatus', url, {method: 'get',
          >parameters: pars});
          > }
          >//---------------------------------------------------------------------
          ></SCRIPT>
          >
          ></HEAD>
          >
          ><BODY onLoad="mySlide r1.placeSlider( )">
          >
          ><TABLE>
          ><TR>
          > <TD COLSPAN="3">
          > <IMG
          >SRC="http://www.micro-active.com/slider/christiaan/sliderbg.gif"
          >NAME="Slider1R ailImg" ID="Slider1Rail Img">
          ><TR>
          > <TD ALIGN="left"> 0
          > <TD ALIGN="center"> Slider 1
          > <TD ALIGN="right"> 10
          ></TABLE>
          ><input type="button" value="save slider value" onclick="saveIt ()" />
          ><SPAN ID="Slider1Valu eText"></SPAN>
          ><SPAN ID="Status"></SPAN>
          >
          ><SCRIPT>
          >
          > mySlider1.write Slider();
          >
          ></SCRIPT>
          >
          ></body>
          ></html>[/color]

          Comment

          • Geoff Cox

            #6
            Re: sending variables via cgi form?

            On 1 Sep 2005 04:27:39 -0700, "Peroli" <peroli@gmail.c om> wrote:

            Peroli,

            Is it possible not to show the slider value?

            <SPAN ID="Slider1Valu eText"></SPAN>

            ie can I have the ID="Slider1Valu eText" as a hidden property?

            Cheers

            Geoff

            Comment

            • Geoff Cox

              #7
              Re: sending variables via cgi form?

              On 1 Sep 2005 04:27:39 -0700, "Peroli" <peroli@gmail.c om> wrote:

              Peroli,

              Have sorted the invisible <span> by using css but one other thing.

              After the slider value has been submitted a message appears saying
              Thank you etc and giving the slider value.

              I do not wish that value to be seen and cannot stop it!

              <input type="hidden" name="redirect"
              value="http://website/path/thanks.htm" />

              does not work - still get the Thank you message!

              What is happening?

              Cheers

              Geoff

              Comment

              • Peroli

                #8
                Re: sending variables via cgi form?

                Hi Geoff,
                Replace the saveIt() with the code given below. You can replace the
                "Status" Span too.

                function saveIt() {
                var url = 'http://yourserver/mail.cgi';
                var pars
                ='sliderVal='+d ocument.getElem entById('Slider 1ValueText').in nerHTML;
                var myAjax = new Ajax.Request(
                url,
                {method: 'get', parameters: pars, onComplete:
                function(){aler t("Mail Sent.")}}
                );
                }
                [color=blue]
                > <input type="hidden" name="redirect"
                > value="http://website/path/thanks.htm" />[/color]

                What are you doing here with this Hidden Input? Is this the output you
                get from AJAX? Info needed.

                Some Info for you.
                1. Learn XMLHTTP or AJAX
                2. Learn Prototype.js and understand it. Good place to start is


                We are calling your cgi script with a cgi param "sliderVal" from
                Javascript using AJAX and displaying the response. If you dont want the
                responsse to be shown, then do nothing in the "onComplete " handler of
                "AJax.Reque st" Object.

                - Peroli Sivaprakasam

                Geoff Cox wrote:[color=blue]
                > On 1 Sep 2005 04:27:39 -0700, "Peroli" <peroli@gmail.c om> wrote:
                >
                > Peroli,
                >
                > Have sorted the invisible <span> by using css but one other thing.
                >
                > After the slider value has been submitted a message appears saying
                > Thank you etc and giving the slider value.
                >
                > I do not wish that value to be seen and cannot stop it!
                >
                > <input type="hidden" name="redirect"
                > value="http://website/path/thanks.htm" />
                >
                > does not work - still get the Thank you message!
                >
                > What is happening?
                >
                > Cheers
                >
                > Geoff[/color]

                Comment

                Working...