Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to download the file on select in jquery combobox.

Posted on 2013-01-04
3
Medium Priority
?
313 Views
Last Modified: 2013-01-16
I have a combo box, it contains some items. Every value has its equivalent .pdf file.

When the user select any option from the Combobox, the corresponding file should get downloaded.

<html>
<head>

</head>
<body>
<form name="f">
      <label>Select your course</label>
      <select id="cmbcourses">
            <option value="">Select Course...</option>
            <option value="BCom.pdf">B.Com</option>
            <option value="BBA.pdf">BBA</option>
            <option value="BCA.pdf">BCA</option>
      </select>
</form>
</body>
</html>
0
Comment
Question by:searchsanjaysharma
  • 2
3 Comments
 
LVL 83

Accepted Solution

by:
leakim971 earned 1500 total points
ID: 38746152
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Q_27985645.html</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
	$("#cmbcourses").change(function() {
		// download.php => http://www.experts-exchange.com/Software/Server_Software/Web_Servers/Apache/Q_25561636.html
		// Ray_Paseur you're the best!
		location.href = "download.php?file="  + $(this).val();
	})
})
</script>
</head>
<body>
<form name="f">
      <label>Select your course</label>
      <select id="cmbcourses">
            <option value="">Select Course...</option>
            <option value="BCom.pdf">B.Com</option>
            <option value="BBA.pdf">BBA</option>
            <option value="BCA.pdf">BCA</option>
      </select>
</form>
</body>
</html>

Open in new window


inside http://www.experts-exchange.com/Software/Server_Software/Web_Servers/Apache/Q_25561636.html
$url = $_GET["file"];
0
 

Author Closing Comment

by:searchsanjaysharma
ID: 38782091
ok
0
 
LVL 83

Expert Comment

by:leakim971
ID: 38782237
ko
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question