Solved

How to download the file on select in jquery combobox.

Posted on 2013-01-04
3
265 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 82

Accepted Solution

by:
leakim971 earned 500 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 82

Expert Comment

by:leakim971
ID: 38782237
ko
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
jQuery force form POST 7 86
Responsive Font Size 6 47
ASP.NET - Why is accordion not working? 3 47
center navbar (navigation menu) on web page 3 18
Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
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…

756 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