Solved

How to download the file on select in jquery combobox.

Posted on 2013-01-04
3
274 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Jquery form 9 65
JavaScript Loan Calculator Error 3 47
DataTable column sorting incorrectly 2 36
How do I init a PHP page jusing JQuery? 8 32
I have answered several questions lately that were solved utilizing the power of jQuery's AJAX functions, so I thought I would write an article demonstrating the ease of use. Why should I use jQuery as opposed to regular JavaScript? Now I know…
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…

751 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