Thanks for your help ,
with your informations, I got it !
>From my principal HTML page, I doubleClick in a input field containing a keyword
to search.
This call the function show().
<html>
<head>
<title>Travail</title>
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
<script src="../js/fonctions.js" language="JavaScript"></script>
<script language="JavaScript" src="../js/fonctionsTableau.js"></script>
<LINK TYPE="TEXT/CSS" HREF="../css/perso.css" REL="STYLESHEET">
</head><BODY BGCOLOR="#ceced5" TEXT="#1f1f1f">
<form action="http:/Sylvie/servlet/SevletMajElement" method="post"
name="form1">
<table cellpadding="0" cellspacing="5" border="0" width="592">
<tr>
<td align="right" width="192">
<font size="-1" face="Arial, Helvetica, sans-serif">An Other
Element</font>
</td>
<td bgcolor="#dfdfdf" align="center" width="106">
<font size="-1" face="Arial, Helvetica, sans-serif">
<input type="text" name="OtherElement" size="10"
maxlength="8" onDblClick="show()" VALUE="CAL009000"></font>
</td>
</tr>
This function uses the SearchingWindow.html (a different HTML page) to do its
submit with the selected keyword.
function show(){
gField = event.srcElement
if (gField.value != null && gField.value != '') {
laWindow =
window.open('../html/SearchingWindow.htm','SearchingWindow','scrollbars=yes,resizable=yes,status=yes,width=650,height=350');
laWindow.status = gField.value;
formObj = MM_findObj('SearchingForm',laWindow.document);
if (formObj != null){
formObj.KeyWord.value = gField.value;
formObj.submit();
laWindow.focus();
}
else
laWindow.close();
}
}
This SearchingWindow.html calls the servlet with the wanted parameters, as if
it was used directly.
Thank again.
Sylvie.
Robert Koberg a écrit :
> Hi,
>
> The form must be on the page that has the button. Here is a simple example
> (watch for line breaks in the M_findObj):
>
> <html>
> <head>
> <title>Untitled Document</title>
> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
> <script language="JavaScript">
> <!--
> // cross platform/browser object finder
> // you could probably use a simpler one just for your form
> function MM_findObj(n, d) { file://v3.0
> var p,i,x; if(!d) d=document;
> if((p=n.indexOf("?"))>0&&parent.frames.length) {
> d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
> if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++)
> x=d.forms[i][n];
> for(i=0;!x&&d.layers&&i<d.layers.length;i++)
> x=MM_findObj(n,d.layers[i].document); return x;
> }
>
> function formSubmit(formaction) {
> // form name could be a parameter too
> formObj = MM_findObj('test');
> formObj.action = formaction;
> alert(formObj.action);
> formObj.submit();
> }
>
> file://-->
> </script>
> </head>
>
> <body bgcolor="#FFFFFF">
> <form name="test" method="post" action="">
> <p>
> <input type="text" name="textfield">
> <br>
> </p>
> <p>
> <input type="text" name="textfield2">
> </p>
> <p>
> <input type="button" name="Button1" value="Button"
> onClick="formSubmit('servlet/TheFirstServlet');">
> <input type="button" name="Button2" value="Button"
> onClick="formSubmit('servlet/TheSecondServlet');">
> </p>
> </form>
> </body>
> </html>
>
> ----- Original Message -----
> From: "PALLUEL Sylvie" <[EMAIL PROTECTED]>
> To: "A mailing list for discussion about Sun Microsystem's Java Servlet API
> Technology." <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
> Sent: Tuesday, February 27, 2001 9:03 AM
> Subject: Re: Question: Call to Servlet (that doesn't generate HTML) from
>
> > Hello,
> > you answered this last day, but I don't understand very well :
> > to do this we need an existing form ? Where must be this form ? In the
> current
> > HTML page or in any HTML file ?
> > My problem is that I'ld like to use two different ways to call my servlet
> :
> > Searching a keyword in database :
> > . using a search form where the user enter the word to search, and click
> on
> > submit (that's ok)
> > . using javascript to click in a input field (part of an other form) which
> > content the word to search , and call my servlet with the selected word as
> > parameter ...
> >
> > Bye,
> > Sylvie.
> >
> >
> > Robert Koberg a écrit :
> >
> > > I posted this the other day. I don't know why people use "location".
> This is
> > > how it should be done:
> > >
> > > <a
> href="javascript:myFormFunction('/servlet/ServletName','formName')>text
> > > or image</a>
> > >
> > > Then in the head of the document (or js include) put a function
> something
> > > like:
> > >
> > > <script>
> > > function myFormFunction(theAction, theForm) {
> > > // custom cross platform function that gets an object..
> > > // create your own or take Dreamweaver's - MM_findObj or something
> like
> > > that
> > > myFormObj = getObject(theForm) ;
> > > // set the action
> > > myFormObj.action = theAction;
> > > myForm.submit();
> > > }
> > > </script>
> > >
> >
>
> ___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html