Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8593281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:57:10+00:00 2026-06-11T23:57:10+00:00

I have tried passing values using javascript like below <script language= javascript type= text/javascript>

  • 0

I have tried passing values using javascript like below

<script language= "javascript" type= "text/javascript">
var num;
function getVal()
{
num=document.getElementById('in').value;
alert(document.getElementById('parm').value);
}
</script>
<body>
<form >
Number : <input type="text" id="in"  ><br/>
<button id="myBtn" onclick="getVal()">Try it</button><br/>  
</form>
<APPLET code="Calc.class" width="100" height="100">
<PARAM name="number" id="parm">
</APPLET>

</body>    
</html>

The alert box displays the entered value on screen but the applet code is not displaying the same. My applet code is

public class Calc extends Applet
{

    private String strDefault = "Hello! Java Applet.";
    public void paint(Graphics g) {
    String strParameter = this.getParameter("number");
    if (strParameter == null)
    strParameter = strDefault;
    g.drawString(strParameter, 10, 10);
    }
}

Can anyone tell me the code to pass and retrieve values to and from param tag to html?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T23:57:11+00:00Added an answer on June 11, 2026 at 11:57 pm

    I think you can specify your parameters from javascript objects like so:

    <applet code="Calc.class" width="100" height="100">
        <param name="number" id="parm" value="&{num};">
    </applet>
    

    However, I’m not sure of the compatibility with IE so you may have to document.write out your applet code injecting the respective parameter values like so:

    <head>
        <script type="text/javascript">
            var num;
    
            function getVal() {
                num = document.getElementById('in').value;
    
                writeAppletTags();
            }
    
            function writeAppletTags() { 
                var container = document.getElementById("applet-container");
    
                container.innerHTML = "<applet code=\"Calc.class\" width=\"100\" height=\"100\">";
                container.innerHTML += "<param name=\"number\" value=\"" + num + "\">";
                container.innerHTML += "</applet>";
            }
        </script> 
    </head>
    <body>
        Number : <input type="text" id="in"  ><br/>
        <button id="myBtn" onclick="getVal()">Try it</button><br/>  
        <div id="applet-container" />
    </body>
    

    Sending POST from Java

    As I said in my comment, this is a little more complicated. You’d have to POST (you could also use GET) your values to a hosted file (can be any server side scripting technology). The following demonstrates this, code taken from here.

    URL url;
    URLConnection urlConnection;
    DataOutputStream outStream;
    DataInputStream inStream;
    
    // Build request body
    String body = "key=value";
    
    // Create connection
    url = new URL("http://myhostedurl.com/receiving-page.php");
    urlConnection = url.openConnection();
    ((HttpURLConnection)urlConnection).setRequestMethod("POST");
    urlConnection.setDoInput(true);
    urlConnection.setDoOutput(true);
    urlConnection.setUseCaches(false);
    urlConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
    urlConnection.setRequestProperty("Content-Length", ""+ body.length());
    
    // Create I/O streams
    outStream = new DataOutputStream(urlConnection.getOutputStream());
    inStream = new DataInputStream(urlConnection.getInputStream());
    
    // Send request
    outStream.writeBytes(body);
    outStream.flush();
    outStream.close();
    
    // Close I/O streams
    inStream.close();
    outStream.close();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i m suffering with Passing values from javascript function to controller in cakephp and
I have tried to append <option> inside <select> using javascript by parsing data from
I have a JavaScript function within a JavaScript function. The JavaScript below inserts some
I have an object, o, and a type, T. I'd like to use reflection
I have a string: {0:16970861903381446063,length:1} I tried converting it to an object using the
I need to pass these values to a javascript function in the head. The
I have a javascript Matrix class for affine transforms, and a function to set
I have a javascript function that takes in a parameter that is given by
<button type=button value=click me onclick=check_me(); /> function check_me() { //event.preventDefault(); var hello = document.myForm.username.value;
Hi I am a newbie to java script. Have issues in passing the string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.