Solved

How to download the file on select in jquery combobox.

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

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…

744 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now