SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Evangelist Alluvian's Avatar
    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?

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,175
    Mentioned
    190 Post(s)
    Tagged
    2 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>

  3. #3
    SitePoint Evangelist Alluvian's Avatar
    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?

  4. #4
    SitePoint Evangelist Alluvian's Avatar
    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.
    I downloaded the .class file with the link at the bottom of the page, is the quoted text above telling me to download the sourcecode and compile it? Why would it not be properly compiled already?

    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.)

  5. #5
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,820
    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="^$">

  6. #6
    SitePoint Evangelist Alluvian's Avatar
    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?

  7. #7
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,175
    Mentioned
    190 Post(s)
    Tagged
    2 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);
    }
    I don't think the applet itself needs to be inside the form tags, but the submit will need to cal a function that gets the selected value before the form gets submitted.
    But if you're interested in changing tha applet code then you should ask for the thread to get moved

  8. #8
    SitePoint Evangelist Alluvian's Avatar
    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.

  9. #9
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,175
    Mentioned
    190 Post(s)
    Tagged
    2 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
    The java file is not complete in and of itself but includes other files that are incorporated into the class file when it's compiled. ie.
    Code:
    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    My guess is that there is newer code somewhere that older IE can't work with, but if you specify the target version, it won't compile with the newer code, and it will then work OK in older IE (and as long as backwards compatability has been maintained, should still work with newer browsers)

  10. #10
    SitePoint Evangelist Alluvian's Avatar
    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.

  11. #11
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,175
    Mentioned
    190 Post(s)
    Tagged
    2 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.html
    HTML 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>
    cross-browser examples using the object tag http://ww2.cs.fsu.edu/~steele/XHTML/appletObject.html
    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
    But you really only need to deal with
    • javascript and Java enabled
    • no javascript and/or no Java
    I'm not sure how I would go about this logically but maybe you or someone else, (or me after a few more coffees) can think of something.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •