SitePoint Sponsor |
|
User Tag List
Results 1 to 11 of 11
-
May 5, 2007, 11:23 #1
- Join Date
- Jan 2007
- Location
- Orlando, FL
- Posts
- 417
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Neat javascript autocomplete applet. Can I get it to post data in a form?
Okay, the following site has a really neat autocomplete java applet that would be perfect for a few places on my site where a user will want to pick one item out of a huge list of items.
http://www.somacon.com/p51.php
What I don't know is if there is a way to put this inside a <form> element and have it post the selected value on submit.
Has anyone worked with something like this in the past? Is this even the right forum?
-
May 5, 2007, 13:26 #2
- Join Date
- Jul 2005
- Location
- West Springfield, Massachusetts
- Posts
- 17,290
- Mentioned
- 198 Post(s)
- Tagged
- 3 Thread(s)
java applet
From the view-source of the page you linked to
HTML Code:<td> <APPLET CODE="JumpToWidget.class" codebase="p52.php" WIDTH="300" HEIGHT="300"> <PARAM NAME="names" VALUE="My Kingdom|Atom Bomb|Beyond The Invisible| ....... "> <PARAM NAME="values" VALUE="19295|19294|19293|19292|19291|19319|19289 ....... "> <PARAM NAME="casesensitivity" VALUE="0"> <PARAM NAME="fontname" VALUE="SansSerif"> <PARAM NAME="fontpointsize" VALUE="11"> </APPLET> </td> <td align=center> <b>Try It</b> <p> <form name="appletform" method="post" action=""> <input type="button" onClick="showSelected();" value="show selected"> <br><input type="button" onClick="loadNewOptions();" value="load alternate options"> </form> The list contains 1956 song names, <br>which you can narrow down to one <br>usually within a few keystrokes. </td>
Big Change Coming Soon - if you want your PMs save them now!
What you need to do to prepare for our migration to Discourse
A New SitePoint Forum Experience: Our Move to Discourse
-
May 5, 2007, 13:37 #3
- Join Date
- Jan 2007
- Location
- Orlando, FL
- Posts
- 417
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Yeah, I saw that sourcecode, neither of those buttons post any data anywhere.
It did just make me realize I could make a hidden textfield, have a submit button where javascript fills in the hidden field with the applet's data before the form is actually submitted... would that work?
-
May 5, 2007, 16:29 #4
- Join Date
- Jan 2007
- Location
- Orlando, FL
- Posts
- 417
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
The page http://www.somacon.com/p51.php works in FF2 and IE6.
I got my example working great in Firefox 2, but it won't work in IE6 or IE7, the applet shows a red x.
I see at the bottom of:
http://www.somacon.com/p51.php
The following text that I do not understand:
Java Compile Command
javac -target 1.1 -classpath %classpath% -verbose -deprecation JumpToWidgetNote: You must specify virtual machine target version 1.1 in order for it to work in Internet Explorer 6.0.
The source code is in the public domain, and the applet is free for any use.
Any help on this? I really like this selection method and would like to use it other places, but I definitely need it working in IE6 and 7. (I will have to do a check for js before showing this version of the selection of course so that it degrades nicely.)
-
May 5, 2007, 16:32 #5
- Join Date
- Sep 2005
- Location
- Sydney, NSW, Australia
- Posts
- 16,875
- Mentioned
- 25 Post(s)
- Tagged
- 1 Thread(s)
Isn't this thread in the wrong forum. It doesn't appear to have anything to do with javaScript.
Stephen J Chapman
javascriptexample.net, Book Reviews, follow me on Twitter
HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
<input name="html5" type="text" required pattern="^$">
-
May 5, 2007, 17:12 #6
- Join Date
- Jan 2007
- Location
- Orlando, FL
- Posts
- 417
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
You are VERY right, sorry thought I was in the java forum. Should I remake the thread or wait for a mod to move it?
-
May 5, 2007, 20:29 #7
- Join Date
- Jul 2005
- Location
- West Springfield, Massachusetts
- Posts
- 17,290
- Mentioned
- 198 Post(s)
- Tagged
- 3 Thread(s)
applet javascript
It is a Java applet, but I thought you posted in the javascript forum because you were interested in using the option selected using it. eg. from the page you linked to:
You can use Javascript to obtain data from the Java applet. The selected option can be accessed in Javascript by calling the applet's getSelectedValue or getSelectedName functions. For example, you could retrieve the selected value and submit it with a form. The JavaScript function below demostrates how to access the name and value.Code:function showSelected() { appletObj = document.applets[0]; selectedValue = appletObj.getSelectedValue().toString(); selectedName = appletObj.getSelectedName().toString(); alert("Value: "+selectedValue+" Name: "+selectedName); }
But if you're interested in changing tha applet code then you should ask for the thread to get movedBig Change Coming Soon - if you want your PMs save them now!
What you need to do to prepare for our migration to Discourse
A New SitePoint Forum Experience: Our Move to Discourse
-
May 6, 2007, 06:24 #8
- Join Date
- Jan 2007
- Location
- Orlando, FL
- Posts
- 417
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I got the form to work in firefox2 with some javascript that used that javascript example to fill out a hidden input field in the form instead of alerting so that I could get the selected value of the applet posted. That worked great, but then the applet turned out not to work in IE6 or 7 but it worked fine in firefox2.
So I wanted some help with the applet itself.
Now TODAY it won't even work in firefox2 even though nothing has changed in the file at all. I just get an error message in the status bar that the applet has failed to load. I had high hopes for this thing too... Since the question now is about getting this applet to work or finding another one that works in a similar fashion, I will just remake the thread in the java forum once I research it a little to see if I cannot easily find another applet that will do what I like.
Unless of course somewhere here has an idea what is wrong or what the quoted block of text in my above post meant.
-
May 6, 2007, 10:19 #9
- Join Date
- Jul 2005
- Location
- West Springfield, Massachusetts
- Posts
- 17,290
- Mentioned
- 198 Post(s)
- Tagged
- 3 Thread(s)
java to class
It means that if you are experimenting with a downloaded class file, you should download the java file and compile it into another class file using the command line
Code:javac -target 1.1 -classpath %classpath% -verbose -deprecation
Code:import java.applet.*; import java.awt.*; import java.awt.event.*; import java.util.*;
Big Change Coming Soon - if you want your PMs save them now!
What you need to do to prepare for our migration to Discourse
A New SitePoint Forum Experience: Our Move to Discourse
-
May 7, 2007, 07:42 #10
- Join Date
- Jan 2007
- Location
- Orlando, FL
- Posts
- 417
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
For some reason the applet randomly does not load right in Firefox 2, and it loads on two of our three systems with IE6 but never on a third system.
I obviously would like a fallback plan if the applet fails to load. I have the current page www.thebrasse.com/lotro/ which does not use the applet at all.
Is there a way to check to see if the applet has loaded properly, and if not then load up the version of the page that does not use it? Would this part use javascript?
So logic like this:
If javascript disabled, load non-fancy page (php code, if php can detect java...)
If javascript enabled, but java applet failed to load, load non-fancy page (this would be after php is done, so would have to be in javascript if it is possible)
if javascript enabled, and the applet loaded properly, dance around with a unicorn under a rainbow that is showering us with delicious skittles.
-
May 7, 2007, 09:16 #11
- Join Date
- Jul 2005
- Location
- West Springfield, Massachusetts
- Posts
- 17,290
- Mentioned
- 198 Post(s)
- Tagged
- 3 Thread(s)
applet and javascript supported
You may want to consider using the object tag, as the applet tag was deprecated in HTML 4.01 and is not supported in XHTML Strict.
You may not need different pages based on what the user has enabled.
If you put "default" content inside the object/applet tag it will show if the applet fails to load. eg. http://java.sun.com/j2se/1.4.2/docs/...sc/applet.htmlHTML Code:<applet codebase="http://java.sun.com/applets/NervousText/1.1" code="NervousText.class" width=400 height=75> <param name="text" value="Welcome to HotJava!"> <hr> If you were using a Java-enabled browser such as HotJava, you would see dancing text instead of this paragraph. <hr> </applet>
As for javascript, I think it's best to show the non-javascript-enabled content by default, and the use javascript to hide it and show the javascript stuff if it's enabled.
There are 4 different scenarios
- no javascript, no Java
- javascript, but no Java
- no javascript, but Java
- javascript and Java
- javascript and Java enabled
- no javascript and/or no Java
Big Change Coming Soon - if you want your PMs save them now!
What you need to do to prepare for our migration to Discourse
A New SitePoint Forum Experience: Our Move to Discourse
Bookmarks