#1
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Location
    city of sin, state of the art
    Posts
    421
    Rep Power
    0

    Question Download File Script based on form options


    hey all!

    i am making an image gallery where people can pick the details of the image that they want and then click a button and based on the values that are entered they will download a certain image

    so i have this form...

    6 radio buttons and a submit.

    O - 72 dpi
    O - 150 dpi
    O - 300 dpi

    O - color
    O - black
    O - white

    (Submit)

    so then the idea would be if they select 150 dpi - black then they would download that proper file, say image1_150_blk.jpg for example

    i dont think it is too hard but yea i dont really know a whole lot of javascript so i could be wrong...but its a fun little project and i would sooo appreciate it if anyone has a script for this, or if you know what you would call this so i could search for it!! i would greatly appreciate ANY advice!!!

    thank you thank you thank you in advance!!!

    ROCK ON!!

    (yes i posted this to the javascript forum but people in there are mean and despite the 22 views no one was kind enough to even reply! thanks!!!! )
    "I hate quotations."
    -ralph waldo emerson-
  2. #2
  3. Bites when cornered
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2003
    Location
    Back from Iraq!
    Posts
    109
    Rep Power
    13
    Must have missed it in the other forum, but something similar to this should work:
    Code:
    <script>
    function do_image()
    {
    	if(document.forms.myform.d72.checked) { var res = 72; }
    	if(document.forms.myform.d150.checked) { var res = 150; }
    	if(document.forms.myform.d300.checked) { var res = 300; }
    
    	if(document.forms.myform.c1.checked) { var color = "clr"; }
    	if(document.forms.myform.c2.checked) { var color = "blk"; }
    	if(document.forms.myform.c3.checked) { var color = "wht"; }
    
    	var image_url = "myimage_" + res + "_" + color + ".jpg";
    	window.location.href = image_url;
    }
    
    </script>
    <!-- Then the form: !-->
    <form action="#" method="get" name="myform">
    
       <input type="radio" name="dpi" id="d72" value="72" checked> - 72 dpi<br>
       <input type="radio" name="dpi" id="d150" value="150"> - 150 dpi<br>
       <input type="radio" name="dpi" id="d300" value="300"> - 300 dpi<br>
    <br>
    <br>
       <input type="radio" name="color" id="c1" value="clr" checked> - Color<br>
       <input type="radio" name="color" id="c2" value="blk"> - Black<br>
       <input type="radio" name="color" id="c3" value="wht"> - White<br>
    
       <input type="submit" value="download" onclick="do_image(); return false;">
    </form>

    HTH
    Obstruct the doors, cause delays, be dangerous.

IMN logo majestic logo threadwatch logo seochat tools logo