473,406 Members | 2,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

i have a problem in passing drop down value in onchange method from jsp to javascript

The error im getting is object expected.

This is my jsp page:

Expand|Select|Wrap|Line Numbers
  1. <%@ page import="java.sql.*" %>
  2. <%
  3. String connectionURL = "jdbc:mysql://localhost/new";
  4. Connection connection = null;
  5. Statement statement;
  6. ResultSet rs;
  7. %>
  8.  
  9. <html>
  10. <head>
  11. <script type="text/javascript" src="Task113.js">
  12. </script>
  13. </head>
  14. <body>
  15.  
  16. <%
  17. String s=request.getParameter("q");
  18. Class.forName("com.mysql.jdbc.Driver");
  19. connection = DriverManager.getConnection(connectionURL, "root", "cng");
  20. statement = connection.createStatement();
  21. rs = statement.executeQuery("SELECT prid FROM project where pid='"+s+"'");
  22. String targetId=request.getParameter("q");
  23. %>
  24.  
  25. <form name="myform1" method="post" action="Task113.jsp">
  26. Projects for Program are :&nbsp;&nbsp;
  27. <select name="project" id="project" style="width: 100px" onChange="showCustomer6('this.value')">
  28.  
  29. <%
  30. while(rs.next())
  31. {
  32. String result=rs.getString(1);
  33. String home="unbounded";
  34. %>
  35. <%
  36. out.println(s+" consist of :<br>");
  37. if(targetId.equalsIgnoreCase("unbounded"))
  38. {%>
  39. <option value="<%= home %>">
  40. <%= home %>
  41. </option>
  42. <%}
  43. else if(targetId.equalsIgnoreCase("Program 1"))
  44. {%>
  45. <option value="<%= result %>">
  46. <%= result %>
  47. </option>
  48. <%}
  49. else
  50. {%>
  51. <option value="<%= result %>">
  52. <%= result %>
  53. </option>
  54. <%}
  55. }
  56. %>
  57. </select>
  58.  
  59. </form>
  60. </body></html>


This is my javascript page:

Expand|Select|Wrap|Line Numbers
  1. var xmlhttp
  2.  
  3. function showCustomer6(str)
  4. {
  5. alert("1");
  6. xmlhttp=GetXmlHttpObject();
  7. if (xmlhttp==null)
  8. {
  9. alert ("Your browser does not support AJAX!");
  10. return;
  11. }
  12. var url="dummy.jsp";
  13. url=url+"?q1="+str;
  14. url=url+"&sid="+Math.random();
  15. xmlhttp.onreadystatechange=stateChanged;
  16. xmlhttp.open("GET",url,true);
  17. xmlhttp.send(null);
  18. }
  19.  
  20. function stateChanged()
  21. {
  22. if (xmlhttp.readyState==4)
  23. {
  24. document.getElementById("txtHint").innerHTML=xmlht tp.responseText;
  25. }
  26. }
  27.  
  28. function GetXmlHttpObject()
  29. {
  30. if (window.XMLHttpRequest)
  31. {
  32. // code for IE7+, Firefox, Chrome, Opera, Safari
  33. return new XMLHttpRequest();
  34. }
  35. if (window.ActiveXObject)
  36. {
  37. // code for IE6, IE5
  38. return new ActiveXObject("Microsoft.XMLHTTP");
  39. }
  40. return null;
  41. }
Edit/Delete Message
Feb 26 '10 #1
4 3400
Dormilich
8,658 Expert Mod 8TB
a little more detail about the error would be incredibly useful (e.g. the line number of the error)
Feb 26 '10 #2
line number 27.The onchange method is not calling the javacript selectCustomer6() method.
Feb 26 '10 #3
Dormilich
8,658 Expert Mod 8TB
remove the quotation marks from this.value, otherwise it’s treated as the string "this.value".
Feb 27 '10 #4
ya i removed it,now the items present in second drop down box is unavailable after selecting a particular one in those.
Feb 27 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Xerxes | last post by:
Hi, how can I pass the returned value from Javascript to PHP? I have: ------------------------------------------------------------------------ ------ if ( x>y) {
1
by: Greg Scharlemann | last post by:
I would like to automatically populate a drop down menu when the page loads based on the selection of an item in a different drop down menu. I made a test page that when drop down #1 changes, drop...
7
by: Dave A | last post by:
I have two events in a form that I am passing. One is to a javascript function, the other is to the same .asp page only with another action to show different data. Onchange is calls the...
4
by: Dan | last post by:
Can anyone offer suggestions on how to do this or if it is possible? I have a form that uses a drop down box and 2 text fields. What I am trying to do is have the value of each text box set by...
1
by: Dan | last post by:
This is one that has me stumped and I need an expert's input. Any ideas why the values from the second script-generated drop down list isn't recognized by the script to add time values to the...
3
by: John Walker | last post by:
Hi, On an ASP.NET page I have a drop down list control. When the user pulls down the list and makes a selection, I perform validation, and if the validation fails I want the selected item in...
2
by: Peter | last post by:
Hello I have the following tag <select name="cat" id="cat" onchange="popUpWin('cmPhaseReload.php?category='+document.getElementById('cat').options.value ,600,600,'yes')" class="tbl_result"...
11
by: tokcy | last post by:
Hi everyone, I am new in php and ajax, i am facing the prob while i click on element of first drop down then in second dropdown all element showl come from database. I mean i have three dropdown 1....
4
by: phpmagesh | last post by:
Hi I am using php and smarty, what i have to do is i have a drop down box with dynamic name, id and values. like <select name="id" id="id" onchange="sample()" > {foreach key=key_data...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.