sending variables via cgi form?

Discussion in 'Javascript' started by Geoff Cox, Sep 1, 2005.

  1. Geoff Cox

    Geoff Cox Guest

    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
    Geoff Cox, Sep 1, 2005
    #1
    1. Advertising

  2. Geoff Cox

    Peroli Guest

    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
    Peroli, Sep 1, 2005
    #2
    1. Advertising

  3. Geoff Cox

    Geoff Cox Guest

    On 1 Sep 2005 02:20:42 -0700, "Peroli" <> wrote:

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



    Peroli,

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

    <SPAN ID="Slider1ValueText"></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.leftValue = 0;
    mySlider1.rightValue = 10;
    mySlider1.defaultValue = 0;

    mySlider1.offsetX = 1;
    mySlider1.offsetY = 1;
    mySlider1.maxSlide = 258;

    mySlider1.onmouseover = "self.status='Try me!'";
    mySlider1.onmousedown = "self.status='You start at
    '+this.getValue(0)";
    mySlider1.onmouseup = "self.status='You end at '+this.getValue(0)";
    mySlider1.onchange = "self.status='The current value is
    '+this.getValue(0)";
    mySlider1.onclick = "this.setValue(this.defaultValue)";

    mySlider1.onchange =
    "document.getElementById('Slider1ValueText').innerHTML =
    ''+this.getValue(0)"

    </SCRIPT>


    </HEAD>

    <BODY onLoad="mySlider1.placeSlider()">

    <TABLE>
    <TR>
    <TD COLSPAN="3">
    <IMG SRC="sliderbg.gif" NAME="Slider1RailImg" ID="Slider1RailImg">
    <TR>
    <TD ALIGN="left"> 0
    <TD ALIGN="center"> Slider 1
    <TD ALIGN="right"> 10
    </TABLE>

    <SPAN ID="Slider1ValueText"></SPAN>

    <SCRIPT>

    mySlider1.writeSlider();

    </SCRIPT>


    </body>
    </html>










    >
    >Anyways, try using XMLHTTP or XMLRequest to post the values to the
    >server.
    >
    >- Peroli Sivaprakasam
    Geoff Cox, Sep 1, 2005
    #3
  4. Geoff Cox

    Peroli Guest

    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.leftValue = 0;
    mySlider1.rightValue = 10;
    mySlider1.defaultValue = 0;

    mySlider1.offsetX = 1;
    mySlider1.offsetY = 1;
    mySlider1.maxSlide = 258;

    mySlider1.onmouseover = "self.status='Try me!'";
    mySlider1.onmousedown = "self.status='You start
    at'+this.getValue(0)";
    mySlider1.onmouseup = "self.status='You end at '+this.getValue(0)";
    mySlider1.onchange = "self.status='The current value
    is'+this.getValue(0)";
    mySlider1.onclick = "this.setValue(this.defaultValue)";

    mySlider1.onchange
    ="document.getElementById('Slider1ValueText').innerHTML
    =''+this.getValue(0)";
    //---------------------------------------------------------------------
    function saveIt()
    {
    var url = 'http://yourserver/sendMail.cgi';
    var pars =
    'sliderVal='+document.getElementById('Slider1ValueText').innerHTML;
    var myAjax = new Ajax.Updater('Status', url, {method: 'get',
    parameters: pars});
    }
    //---------------------------------------------------------------------
    </SCRIPT>

    </HEAD>

    <BODY onLoad="mySlider1.placeSlider()">

    <TABLE>
    <TR>
    <TD COLSPAN="3">
    <IMG
    SRC="http://www.micro-active.com/slider/christiaan/sliderbg.gif"
    NAME="Slider1RailImg" ID="Slider1RailImg">
    <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="Slider1ValueText"></SPAN>
    <SPAN ID="Status"></SPAN>

    <SCRIPT>

    mySlider1.writeSlider();

    </SCRIPT>

    </body>
    </html>
    Peroli, Sep 1, 2005
    #4
  5. Geoff Cox

    Geoff Cox Guest

    On 1 Sep 2005 04:27:39 -0700, "Peroli" <> wrote:

    >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,

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

    Cheers

    Geoff







    >
    >- 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.leftValue = 0;
    > mySlider1.rightValue = 10;
    > mySlider1.defaultValue = 0;
    >
    > mySlider1.offsetX = 1;
    > mySlider1.offsetY = 1;
    > mySlider1.maxSlide = 258;
    >
    > mySlider1.onmouseover = "self.status='Try me!'";
    > mySlider1.onmousedown = "self.status='You start
    >at'+this.getValue(0)";
    > mySlider1.onmouseup = "self.status='You end at '+this.getValue(0)";
    > mySlider1.onchange = "self.status='The current value
    >is'+this.getValue(0)";
    > mySlider1.onclick = "this.setValue(this.defaultValue)";
    >
    > mySlider1.onchange
    >="document.getElementById('Slider1ValueText').innerHTML
    >=''+this.getValue(0)";
    >//---------------------------------------------------------------------
    > function saveIt()
    > {
    > var url = 'http://yourserver/sendMail.cgi';
    > var pars =
    >'sliderVal='+document.getElementById('Slider1ValueText').innerHTML;
    > var myAjax = new Ajax.Updater('Status', url, {method: 'get',
    >parameters: pars});
    > }
    >//---------------------------------------------------------------------
    ></SCRIPT>
    >
    ></HEAD>
    >
    ><BODY onLoad="mySlider1.placeSlider()">
    >
    ><TABLE>
    ><TR>
    > <TD COLSPAN="3">
    > <IMG
    >SRC="http://www.micro-active.com/slider/christiaan/sliderbg.gif"
    >NAME="Slider1RailImg" ID="Slider1RailImg">
    ><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="Slider1ValueText"></SPAN>
    ><SPAN ID="Status"></SPAN>
    >
    ><SCRIPT>
    >
    > mySlider1.writeSlider();
    >
    ></SCRIPT>
    >
    ></body>
    ></html>
    Geoff Cox, Sep 1, 2005
    #5
  6. Geoff Cox

    Geoff Cox Guest

    On 1 Sep 2005 04:27:39 -0700, "Peroli" <> wrote:

    Peroli,

    Is it possible not to show the slider value?

    <SPAN ID="Slider1ValueText"></SPAN>

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

    Cheers

    Geoff
    Geoff Cox, Sep 1, 2005
    #6
  7. Geoff Cox

    Geoff Cox Guest

    On 1 Sep 2005 04:27:39 -0700, "Peroli" <> 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
    Geoff Cox, Sep 1, 2005
    #7
  8. Geoff Cox

    Peroli Guest

    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='+document.getElementById('Slider1ValueText').innerHTML;
    var myAjax = new Ajax.Request(
    url,
    {method: 'get', parameters: pars, onComplete:
    function(){alert("Mail Sent.")}}
    );
    }

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


    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
    http://www.sergiopereira.com/articles/prototype.js.html

    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.Request" Object.

    - Peroli Sivaprakasam

    Geoff Cox wrote:
    > On 1 Sep 2005 04:27:39 -0700, "Peroli" <> 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
    Peroli, Sep 2, 2005
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Piet Puk
    Replies:
    1
    Views:
    414
    brucie
    Apr 6, 2004
  2. El Kabong

    sending an html form via E-mail.

    El Kabong, Apr 20, 2007, in forum: HTML
    Replies:
    10
    Views:
    725
    Bergamot
    Apr 21, 2007
  3. tamaker
    Replies:
    3
    Views:
    150
    Anthony Jones
    Dec 13, 2007
  4. Stefan Fischer
    Replies:
    2
    Views:
    236
    Stefan Fischer
    Feb 23, 2010
  5. Jofio
    Replies:
    2
    Views:
    85
    Jofio
    May 20, 2005
Loading...

Share This Page