From: Atkinson, J. (AGRE) <Joh...@sm...> - 2004-04-13 19:21:39
|
I can't seem to get a form to propegate values from a Select Input, could= you please give me a little help? I wrote a small page to test this= functionality, so I will include this page here as well as my testing code= and the results I'm getting. Page1.html ----------------------------------------------------------------- <HTML> <HEAD> <TITLE>TEST PAGE 1</TITLE> </HEAD> <BODY> <FONT SIZE=3D"12" COLOR=3D"red">THIS IS PAGE 1</FONT> <FORM name=3D"Form1" method=3D"POST" enctype=3D"multipart/form-data"= action=3D"Page2.html"> <SELECT NAME=3D"select0" > <OPTION VALUE=3D"Zero" SELECTED>0</OPTION> <OPTION VALUE=3D"One">1</OPTION> <OPTION VALUE=3D"Two">2</OPTION> <OPTION VALUE=3D"Three">3</OPTION> <OPTION VALUE=3D"Four">4</OPTION> </SELECT> <BR><BR> <INPUT name =3D "newFile" type=3D"file" size=3D"42" value=3D""> <BR> <SCRIPT LANGUAGE=3DJavaScript> function processform() { document.forms[0].action=3D"Page2.jsp"; var nextElement =3D document.forms[0].elements[0]; if(nextElement.name =3D=3D "select0")=0D { var selection =3D new String(nextElement.value); alert("Selection =3D '" + selection + "'"); }//end of if statement document.forms[0].submit(); }//end of processform function </SCRIPT> </FORM> <A HREF=3D"javascript:processform()">PAGE2</A> =0D =0D </BODY> </HTML> ----------------------------------------------------------------- Test.java ----------------------------------------------------------------- WebClient webClient =3D new= WebClient(BrowserVersion.INTERNET_EXPLORER_6_0); URL url =3D new URL("http://edms.si.com/Windchill/jsatest/Page1.html"); HtmlPage page =3D ((HtmlPage) webClient.getPage(url)); =0D HtmlAnchor Page2_Link =3D getLinkWithText(page,"PAGE2"); page =3D ((HtmlPage) Page2_Link.click()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ public HtmlAnchor getLinkWithText(HtmlPage page, String text) { java.util.List links =3D page.getAnchors(); for(int i=3D0; i<links.size(); i++) { HtmlAnchor currLink =3D ((HtmlAnchor) links.get(i)); =0D String currLink_Text =3D currLink.asText(); if(currLink_Text.indexOf(text) >=3D 0) { return currLink; }//end of if statement }//end of for loop =0D return null; }//end of getLinkWithText method ----------------------------------------------------------------- Output ----------------------------------------------------------------- Apr 13, 2004 3:08:43 PM= com.gargoylesoftware.htmlunit.javascript.host.Window jsFunction_alert WARNING: window.alert("Selection =3D ''") no alert handler installed ----------------------------------------------------------------- Thank you in advance for your assistance in this matter. Regards, John S. Atkinson ~Smiths Aerospace~ ****************************************** The information contained in, or attached to, this e-mail, may contain= confidential information and is intended solely for the use of the= individual or entity to whom they are addressed and may be subject to= legal privilege. If you have received this e-mail in error you should= notify the sender immediately by reply e-mail, delete the message from= your system and notify your system manager. Please do not copy it for any= purpose, or disclose its contents to any other person. The views or= opinions presented in this e-mail are solely those of the author and do= not necessarily represent those of the company. The recipient should= check this e-mail and any attachments for the presence of viruses. The= company accepts no liability for any damage caused, directly or= indirectly, by any virus transmitted in this email. ****************************************** |