Solved

How to download the file on select in jquery combobox.

Posted on 2013-01-04
3
260 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 Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
The viewer will learn how to dynamically set the form action using jQuery.
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…

840 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