GeeCON Prague 2014*
The moose likes JSP and the fly likes Having trouble with javascript ... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » JSP
Bookmark "Having trouble with javascript ..." Watch "Having trouble with javascript ..." New topic
Author

Having trouble with javascript ...

Rekha Pande
Ranch Hand

Joined: Jan 29, 2004
Posts: 145
hi all....
I have this text box whose data i'm getting from the pop up calendar through the following code ..

So when ever i select any thing in the pop up calendar it is (the date) entered into the text box named dc ...
Now i have a combo box named cmb In which i want to display the data on the selection of the date in the pop up calendar...
How will i do that...???
What i mean is how will i pass my the date that i have selected in the pop up calendar into my sql query so i can fetch the data according to the date that is there in the text box dc..!
Do i have to make a data base connection ??? if so HOW ... other wise plz tell me how to pass the value from the textbox to a java script and then to my java program ....
and yeh one more thing ... like when i select something in the pop up calendar ..data is filled in the text box dc ... there are many function in an html form like onFocus(), onblur() etc ... is there any function to identify that a data has been filled in the text box right now and that can be passed to other variables.. if so what is it...???
So in short all i want is a way that will get me the value that i have selected from the pop up calendar or from the text box when it is filled .. and then to use it in my query ..or pass it to a variable in the java program!!
Plz help ..!
Thank u
[EDIT: Changed the code so fit page better]
[ April 22, 2004: Message edited by: Eric Pascarello ]
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
JavaScript can not connect to a database and since this is a Java Forum I am gussing you can use a server side language named JSP.
What you need to do is post back the page after that item has been changed, the jsp then finds the value and runs the SQL query and fills in the data.
I am going to move this to the JSP Forum.
Eric
Rekha Pande
Ranch Hand

Joined: Jan 29, 2004
Posts: 145
I think what i wrote was not clearly understood...!!!
What i meant was that .. i have this java script through which a pop up calendar is displayed....
What i wanted to do is that when ever i select any value in the pop up calendar the jsp page should be reloaded ...
The selected value goes into a txt box and then in the combo box the data should be displayed in accordance with the date selected ...!!
The javascript works this way
There is a image and this image hyper links to the pop up calendar...
What i want is that when i select any thing in the pop up calendar .. it should display data accordingly in the combo box...what i mean is that
1. First select the date
2. The date to be displayed in the text box
I know that data base connectivity is not possible through java script but plz can some one tell me how to detect whether a text box has been filled right now.......
For eg:
When i select something in the pop up .. is there some way that i can capture an event ...that something has been filled in the txt box right now ...so refresh the page and then take the value of the txt box through request.getParameter("Textboxname")';


plz some one help me out on this one.... i thought that this was a java script question but i have been directed to jsp..!
Plz some one help me on this one..!
Thanxzzzz..!
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
You need to submit the form backl to the jsp so it can fill in the values
javascript code:
parent.document.FormName.Submit();
Call it after the date is placed in the field from the pop up code...
Eric
Rekha Pande
Ranch Hand

Joined: Jan 29, 2004
Posts: 145
That's exactly what my question is ....
See the problem that i'm facing is that .. the onKlick code is on the image which is hyper linked .. and what actually happens in the program is that when i click on the image the calendar appears .... i.e. the iframe code ...through which the calendar appears ....
NOW is there a way i can attach a java script code on the click of the iframe ..(please see the code above) coz i tried to attach a refresh java script code on the onclick of the iframe ... but it didn't work ... ! Does the iframe have any onclick thing ..!???
Could u plz help me on just one thing:
-------------------------------------
In my code the onChange event doesnot get triggered ... even though the text box data is getting changed ... i'm posting my code below ... plz do let me know where i am going wrong...
Only when i select the text box and write something into it and then press the tab key then the onChange event gets triggered .....
Plz could u rectify my code such that when ever any thing is selected into the text box ..a event should be fired saying that the text box data changed..!
Plz note that the event is to be on the text changed of the text box and not on combo selection
ur help will be really apprecaited
Thanxs
code.......
<HTML>
<HEAD>
<script language = "javascript">
function check(pass)
{
var db=pass;
return db;
}
</script>
<script language = "javascript">
function check1()
{
document.forms[0].submit();
}
</script>
<script language = "javascript">
function check2()
{
alert('changed');
}
</script>
<TITLE>Hello World!</TITLE>
</HEAD>
<FORM name="demoform">
<body>
<%String test = "";
String test2 = "default";
if(request.getParameter("D1")!=null)
{
test = request.getParameter("D1");
}
test2 = test;
%>
Date Field:
<input name="dc" onChange = "check2();" size="11" value = <%=test%> > 

<select size="1" name="D1" onChange = "check1();">
<option selected>Select Time wanted</option>
<option>dasdas</option>
<option>22</option>
<option>44</option>
</select><p> </p>
<p> </p>
<p> </p>
<p>
</form>
</BODY>
</HTML>
 
GeeCON Prague 2014
 
subject: Having trouble with javascript ...