473,581 Members | 2,304 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Submit onchange doesn't work

8 New Member
I really can't see what's wrong in my code... the submit() onChange doesn't work..

I've tried..

Expand|Select|Wrap|Line Numbers
  1. <select name="ddlTestCenter" id="ddlTestCenter" style="width:180px" onChange="this.form.submit();">
it doesn't work...

Expand|Select|Wrap|Line Numbers
  1. <input type="hidden" name="hiddenopt" value="secret"> <select name="list" onChange="document.forms['try'].submit();">
this one work on my test page.. but it didn't work when i embed it on my project..

here is the complete code of my webApp.. I'll truly appreciate and be grateful of whatever help you'll be able to give.. thanks in advance...

<%@ page import="java.sq l.*" %>
<%@ page import="java.io .*" %>
<%@ page import ="java.util. *" %>
<%@ page import="java.te xt.*" %>
<%@page import ="java.lang. *" %>


[HTML]<html>
<head>

<LINK href="Admin/css/format.css" type="text/css" rel="stylesheet ">

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>WBITE Index</title>
<table width="100%" bgcolor="#FFFFF F">
<tr> <td height="10"></td></tr>
<tr>
<td width="159" height="45" align="right">
<img src="Admin/Images/logor.gif" width="159" height="45" /></td>
<td width="100%" valign="bottom" align="left">
<img align="bottom" src="Admin/Images/header.gif" alt="header" />
</td>
</tr>
<tr>
<td colspan="2" align="center" width="100%" background="Adm in/Images/lineB.gif" height="23" valign="top">
</td>
</tr>


</table>
<script language="Javas cript" type="text/javascript">
function matchPassword(p assword,otherpa ssword)
{
document.getEle mentById("passw ord_match_statu s").style.displ ay="";
if (password == otherpassword)
{
document.getEle mentById("passw ord_match_statu s").style.displ ay="<img src="../Images/ImageButtons/approve_ovr.gif "> Passwords Match";
}

else {
document.getEle mentById("passw ord_match_statu s").style.displ ay = "<img src="../Images/ImageButtons/disapprove_ovr. gif"> Passwords Do Not Match";
}
}


function reloadForm(){
document.regExa minee.action = "regExaminee.js p";
document.regExa minee.submit();
}


function populate(){

ddlTestCenter = document.getEle mentById("regEx aminee");
ddlTestCenter = "ddlExamSchedul e.do";
ddlTestCenter.s ubmit();

}

</script>
</head>

<body>

<!--header-->
<table width="100%">
<!--DWLayoutTable-->
<tr>
<td width="400" rowspan="4" align="center" valign="top">
<table width="400" cellpadding="3" cellspacing="0" bgcolor="#FEE9C B">


<input type="hidden" name="_submitte d" value="1">
<input type="hidden" name="next" value="/">
<input type="hidden" name="tzoffset" value="">
<tr>
<td colspan="5" valign="top" bgcolor="#FBEFE F" align="center" width="400">
<table width="400" bgcolor="#FEE9C B" border="2">
<!--DWLayoutTable-->
<tr>
<td height="20" colspan="5" align="left" style="color:#F FFFFF; font-weight:bold; background-color:#641A00"> Register Examinee </td>
</tr>
<tr>
<td align="center" valign="top" width="400" >


<form name="regExamin ee" method="post" action="regExam inee.jsp" >

<!--Start of Registration Form-->
<%
String testCenter = request.getPara meter("ddlTestC enter");
String driver = "com.mysql.jdbc .Driver";
String url = "jdbc:mysql ://192.168.0.9:330 6/WBITE?user=root ";
Connection con = null;
ResultSet rs = null;
ResultSet rs2 = null;
Statement stmt = null;
con = DriverManager.g etConnection(ur l);
stmt = con.createState ment();
%>
<table cellpadding="3" bgcolor="#FEF9E 9" width="400">
<tr>
<td style="text-align:right!imp ortant;width:13 0px">Test Center:</td>
<td>
<input type="hidden" name="hiddenopt " value="secret">

<select name="ddlTestCe nter" id="ddlTestCent er" style="width:18 0px" onChange="this. form.submit();" >

<option value="javascri pt:void(0)">- Test Center -</option>
<%

try {
rs = stmt.executeQue ry("CALL `WBITE`.`uspSel ectTestCenter`( )");
while (rs.next()) {
if(testCenter == rs.getString(1) ){
%>
<option name="ddlTestCe nterOption" id="ddlTestCent erOption" value="<%=rs.ge tString(1)%>" selected="selec ted"> <%=rs.getString (1)+" ("+ rs.getString(2) +")"%></option>
<%
}

else
{
%>
<option name="ddlTestCe nterOption" id="ddlTestCent erOption" value="<%=rs.ge tString(1)%>"> <%=rs.getString (1)+" ("+ rs.getString(2) +")"%></option>
<%
}
}
} catch (Exception e) {
System.out.prin tln(e);
}
%>
</select>
</td>
</tr>
<tr>
<td style="text-align:right!imp ortant;width:13 0px">Exam Schedule:</td>
<td>
<select name="ddlExamSc hedule" id="ddlExamSche dule" style="width:18 0px"" >
<option value="">- Exam Schedule -</option>
<%
if (testCenter!=nu ll)
{
try {
rs2 = stmt.executeQue ry("SELECT * FROM WBITE.examSched ule e where TestCenterName= '"+testCenter+" ';");
while (rs2.next()) {
%>
<option name="ddlExamSc hedule" id="ddlExamSche dule" value="<%=rs.ge tString(5)%>"> <%=rs.getString (2)+" ("+ rs.getString(3) +"-"+rs.getString( 4)+")"%></option>
<%}
} catch (Exception e) {
System.out.prin tln(e);
}
} %>
</select>
</td>
</tr>
<tr>
<td style="text-align:right!imp ortant;width:15 0px">Username: </td>
<td>
<input type="text" name="txtUserNa me" id="reg_usernam e" value="" maxlength="100" style="width:18 0px">
</td>
</tr>
<tr>
<td style="text-align:right !important;">Pa ssword:</td>
<td>
<input type="password" name="txtPasswo rd" id="txtPassword " value="" maxlength="17" style="width:18 0px"></td>
</tr>
<tr>
<td style="text-align:right !important;">Re-enter password: </td>
<td width="227" >
<input style="width:18 0px" type="password" name="txtPasswo rd2" id="txtPassword 2" maxlength="17" onKeyUp="match( this.value,txtP assword.value) " >
</td>
</tr>

<tr id="rowPassword " style="display: none">
<td> </td>
<td><span id="password_ma tch_status"><im g src="../Images/ImageButtons/disapprove_ovr. gif" alt="Does Not Match" width="35" height="25"> Passwords Do Not Match</span></td>
</tr>

<tr>
<td style="text-align:right !important;">Fi rst Name:</td>

<td><input style="width:18 0px" name="txtFirstN ame" maxlength="15" value="" type="text" onFocus="docume nt.getElementBy Id("rowPassword ").style.displa y=''"></td>
</tr>
<tr>
<td style="text-align:right !important;">La st Name:</td>
<td><input type="text" name="txtContac tNum" id="txtContactN um" value="" maxlength="100" style="width:18 0px" > </td>
</tr>
<tr>
<td style="text-align:right!imp ortant;width:13 0px">Contact Number:</td>
<td>
<input type="text" name="txtContac tNum" id="txtContactN um" value="" maxlength="100" style="width:18 0px" > </td>
</tr>
<tr>
<td style="text-align:right!imp ortant;width:13 0px">Email Address:</td>
<td>
<input type="text" name="txtEmailA dd" id="txtEmailAdd " value="" maxlength="100" style="width:18 0px" > </td>
</tr>


<tr>
<td style="text-align:right !important;">Ge nder:</td>
<td valign="middle" >
<input name="rdioGende r" type="radio" value="Male" checked>Male
<input name="rdioGende r" type="radio" value="Female"> Female

</td>
</tr>

<tr><td height="17"></td></tr>
<tr>
<td></td>
<td colspan="2">

<input type="submit" name="submit" value="Register Examinee">

</td>
</tr>
</table> <!--END of Registration Form-->

</form>


</td>

</tr>
<!--HOLDS the LARGEST ROW contains both forms-->
</table>
</td>
</tr>
</table>

<!--DIV: Boxcontent -->

</td>

</tr>
<tr>
<td height="5"></td>
</tr>
</table>

</body>
</html>[/HTML]
Aug 25 '08 #1
15 3055
RamananKalirajan
608 Contributor
[HTML]function populate(){

ddlTestCenter = document.getEle mentById("regEx aminee");
ddlTestCenter = "ddlExamSchedul e.do";
ddlTestCenter.s ubmit();

} [/HTML]

please replace the code with

[HTML]function populate(){

ddlTestCenter = document.getEle mentById("regEx aminee");
ddlTestCenter.a ction = "ddlExamSchedul e.do";
ddlTestCenter.s ubmit();

} [/HTML]

this. Hope this will work. try it and post back ur result

Regards
Ramanan Kalirajan
Aug 25 '08 #2
colyn7
8 New Member
thanks but it still didn't work..

Do I still need a helper of some class.. cause i kinda receive an error that there is a missing file in cgi-bin...

what could it be? am not using any tool in web app cause my pc is rather slow.. 512mb only, am using notepad++.. it would have been much easier if i'm using eclipse or netbeans cause it has some helper...

please.. anyone.. I was able to see the page.. but when i'll select an option, it won't reload the page or submit it when onChange on select option...

i hope someone will be able to help me on this...thanks..
Aug 25 '08 #3
RamananKalirajan
608 Contributor
thanks but it still didn't work..

Do I still need a helper of some class.. cause i kinda receive an error that there is a missing file in cgi-bin...

what could it be? am not using any tool in web app cause my pc is rather slow.. 512mb only, am using notepad++.. it would have been much easier if i'm using eclipse or netbeans cause it has some helper...

please.. anyone.. I was able to see the page.. but when i'll select an option, it won't reload the page or submit it when onChange on select option...

i hope someone will be able to help me on this...thanks..
Hi for that function u have never made a call. Please explain me ur requirement dont confuse with ur codes. Just post onchange of the select the control should transfer to which page. On which component you want to make submit. please explain that clearly. I will surely help u out.

Regards
Ramanan Kalirajan
Aug 25 '08 #4
Ferris
101 New Member
try this:

<select name="list" onChange="docum ent.getElements ByName['regExaminee'][0].submit();">
Aug 25 '08 #5
acoder
16,027 Recognized Expert Moderator MVP
colyn7, welcome to Bytes! Please remember to follow the posting guidelines when posting in the forum. Code tags are important as are good thread titles. I've added the missing code tags and changed the thread title for you. Please use a good one in future. Thanks!
Aug 25 '08 #6
colyn7
8 New Member
colyn7, welcome to Bytes! Please remember to follow the posting guidelines when posting in the forum. Code tags are important as are good thread titles. I've added the missing code tags and changed the thread title for you. Please use a good one in future. Thanks!
thanks a lot.. am still a newbie here.. Thanks...
Aug 25 '08 #7
RamananKalirajan
608 Contributor
thanks a lot.. am still a newbie here.. Thanks...
Wether u got ur code working

Regards
Ramanan Kalirajan
Aug 25 '08 #8
colyn7
8 New Member
hmm.. thank you very much for the suggestion..

regarding the functions.. those are the functions i've tried calling onChange at select options.. but it didn't seem to work out..

On our project, the second option is dependent on the first selection..

that's why I have to submit the first selection for the second selection to appear...

But I can't submit it so far.. the page should reload when submitted, right? It didn't..

I think something's wrong on my following codes... that has nothing to do with the onChange.. because I've tried replacing my codes with this..

Expand|Select|Wrap|Line Numbers
  1. <Form Name="try"> <input type="hidden" name="hiddenopt" value="secret"> <select name="list" onChange="document.forms['try'].submit();"> <option value="1">First option</option> <option value="2">Second option</option> <option value="3">Third option</option> </select></form>
it seems to work out.. so i think the problem is not on the function but on the codes somewhere.. all my options comes from our database.. that's why its so hard on me.. But, I also tried removing the JSP codes from it and replace the options this
Expand|Select|Wrap|Line Numbers
  1. <select name="list" onChange="document.forms['try'].submit();"> <option value="1">First option</option> <option value="2">Second option</option> <option value="3">Third option</option> </select>
even though I've replaced it (the select options only not the whole form), it didn't work out...

I mean.. When I replaced the whole form, it worked out.. but when i replaced the select options only, it didn't.. Both removing the JSP codes.. what could be the problem on my codes?
Aug 25 '08 #9
acoder
16,027 Recognized Expert Moderator MVP
On our project, the second option is dependent on the first selection..

that's why I have to submit the first selection for the second selection to appear...
That's not strictly true because you could use Ajax or load all the options and call a JavaScript function to change the options onchange, but what you're trying should also work.

I notice in your first post that some of the hidden fields are outside the form. What you've posted in the last post didn't work because the form isn't named "try".
Aug 25 '08 #10

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

Similar topics

2
8666
by: Jason Novotny | last post by:
Hi, I'm trying to create a listbox using <select> HTML tags that can do a form submit when an option in the list is selected. So far this works, function MySelectSubmit() { document.myform.submit(); }
9
2716
by: scott | last post by:
I have a combo in LISTING 2 that I'm trying to force a sumbit when a user makes a change. Can anyone see why it doesn't fire LISTING 2 code? It just doesn't do anything. What I'm really trying to do is access the value of the combo after a user makes a change. I'm just hardcoding the teamID querystring in this example. LISTING 1...
2
7035
by: Andy Goldstein | last post by:
I have a table where all the TRs have an onClick handler registered. One (and only one) of the rows has 2 text input boxes, where each textbox has an onChange handler registered. Both the onClick and onChange handlers do some minor manipulation of form data (although they work on different form elements). If the onChange event fires, I need...
6
2737
by: charlie_M | last post by:
I figured out via various help from this forum... EXAMPLE: onClick="document.forms.MYBUTTON.value='SIMPLE';document.forms.submit()" In my CGI I see "MYBUTTON" = "SIMPLE" and this works fine.... except that the element MYBUTTON must exist as a hidden field.
2
22272
by: a10392 | last post by:
Hi, I'am triyng to create a form where i have 2 comboBox and 2 textbox, when the selection changes on the first combo , the content of second also changes. i have to use onchange=form.submit() the problem is, i want to have a button to finish the selection and save all the data to a database, but if i have diferent forms, i will not get the...
5
3449
by: Pascal Batzli Jr | last post by:
Hello, I have a strange situation happening on the code below. When I first load the page, as I change any of the three combo boxes I have created, the onchange event is fired and the form should be submitted, but it isn't for some weird reason. However, after I press the ok button, it submits the form, and then the combo boxes start working...
5
2240
by: awebguynow | last post by:
to submit or not to submit - that is the question and I'm going to be designing some lengthy forms, where many of the fields may be populated with data, and the user may only want to view it. In a perfect world, I'd have 2 buttons: Close and Submit - disabled and Submit would become enabled - immediately - if data was changed....
2
4652
by: somaskarthic | last post by:
Hi In my php code , i dynamically created table rows on button click event. Each row contain 3 selectboxes, 7 checkboxes . On each click of these elements i need to submit the form and save the data to database. After each submit , i need to display the previous added details (with some checkboxes checked and some others unchecked ..) and one...
14
75468
by: white lightning | last post by:
How to have <select onchange="this.form.submit()"and also a Submit button on one form? I have something like this: <form action="<?php $_SERVER; ?>" method="post" enctype="multipart/form-data" name="form1"> <select onchange="this.form.submit();" name="prod"> <option value="">Select product</option> <option value="12">abc</option>
0
7868
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8149
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8304
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7899
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6553
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5674
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3805
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3827
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1138
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.