Getting content of alert message into textfield

Ads
 

Getting content of alert message into textfield

how to get content of alert message into textfield using javascript

View Answers

February 25, 2011 at 3:13 PM

Getting content of alert message into text field

1)If you want the code in java, then here is it:

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

class  Validation{
    public static void main(String[] args){
        JFrame f=new JFrame();
        f.setLayout(null);
        final JRadioButton radio=new JRadioButton("Select");
        final JCheckBox  check=new JCheckBox("Check");
        final JTextField text=new JTextField(20);
        JButton b=new JButton("Check");
        b.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e){
            if(radio.isSelected()&&!check.isSelected()){
                String st="You have selected radiobutton instead of checkbox";
            JOptionPane.showMessageDialog(new JFrame(), st, "Dialog",JOptionPane.ERROR_MESSAGE);
            text.setText(st);
              }
              else{
              text.setText("");
              }
            }
        });
   radio.setBounds(10,10,100,20);
   check.setBounds(10,40,100,20);
   b.setBounds(10,70,100,20);
   text.setBounds(10,110,200,20);
   f.add(radio);
   f.add(check);
   f.add(b);
   f.add(text);
   f.setVisible(true);
   f.setSize(300,200);
   }
}

2)If you want the code in html-javascript, then here is it:

<html>
<script>
function check(){
var ch=document.getElementById('check');
var r=document.getElementById('radio');
if(r.checked&&!ch.checked){
var st="You have selected radiobutton instead of checkbox";
alert(st);
document.getElementById("text").value=st;
}
else{
document.getElementById("text").value="";
}
}
</script>
Select<input type="radio" id="radio"><br>
Check<input type="checkbox" id="check"><br>
<input type="button" value="check" onclick="check();"><br>
<input type="text" id="text">
</html>

Ads









Related Tutorials/Questions & Answers:
Getting content of alert message into textfield
Getting content of alert message into textfield  how to get content of alert message into textfield using javascript   Getting content of alert message into text field 1)If you want the code in java, then here
Getting content of alert message into textfield
Getting content of alert message into textfield  how to get content of alert message into textfield using javascript   Getting content of alert message into text field 1)If you want the code in java, then here
Advertisements
GETTING ALERT MESSAGE
GETTING ALERT MESSAGE  how to get an alert message when radio button is selected instead of checkbox
GETTING AN ALERT MESSAGE
GETTING AN ALERT MESSAGE  how to get an alert message, if i select radio button instead of checkbox(associated with 3 dropdown list
Javascript alert message
Javascript alert message   How to send an alert message to a user in JavaScript
Getting message from the server using RPC( Remote Procedure Call )
Getting message from the server using RPC( Remote Procedure Call... describes the procedure of retrieving message from the server via RPC. The steps involved in geting message from the server are described below:- Step1:-Right
how to create alert message after data submitted into database
how to create alert message after data submitted into database  I want to create alert message box after data stored into database and redirect to another page, how to do
How to Display an alert message when nothing is selected in jspinner in java?
How to Display an alert message when nothing is selected in jspinner in java... minimum", "Alert", JOptionPane.ERROR_MESSAGE); x = 1; } return x; } the Alert message is never displayed,please i need help. Thank
autogeneration of a random number and displaying it as a alert message to the user on clicking submit
autogeneration of a random number and displaying it as a alert message to the user on clicking submit  Hi, In my project order purchase system under... on the submit button as a "alert message" and this refrence number act as primary key
alert
alert  after pressing ok button in alert message it has to stop...; if(username==""){ alert("Enter Username!"); return false; } if(password==""){ alert("Enter Password!"); return false; } return true; } </script> <
Creating, getting, and setting content using jQuery
Creating, getting, and setting content using jQuery       Creating, getting, and setting content using jQuery Using jQuery , you can add(create) html content
If statement doesn't work ,(doesn't print alert message when user dont field name and email)
If statement doesn't work ,(doesn't print alert message when user dont field... { echo ""; echo "alert('Message failed. Please, send an email...']; $fieldmessage = $POST['cf_message']; $mail_to = '[email protected]
TextField on the Image
TextField on the Image  how we set label or textfield etc. on the Image
Java Alert Box
JOptionPane class to display the message alert box.  JOptionPane class is available...Java Alert Box In this example we will describe java alert box. First of all we have created class than main method after that we have created alert box
TextField validations
TextField validations  I want to know How to check first letter... textfield? and also want to know how to check all digits or not in a textfield? ex... are allowed!","Error!", JOptionPane.ERROR_MESSAGE); text1.setText
Java textfield validaton
Java textfield validaton  Sir... i'm new to java. In java JTextfield when we entered a negative value after pressing one button it have to display an error message dialog of textfield and also the textfield should accept
Java textfield validaton
Java textfield validaton  Sir... i'm new to java. In java JTextfield when we entered a negative value after pressing one button it have to display an error message dialog of textfield and also the textfield should accept
TextField validations
TextField validations  I want to know How to check first letter capital or not in a text field and also check all are characters or not in same textfield? and also want to know how to check all digits or not in a textfield? ex
alert in jsp
alert message?, please give me a code how to write alert box in jsp...alert in jsp  if(pass.equals(pwd)) { Statement st1..."); %> alert("password is successfully changed"); <
java textfield problem
java textfield problem  I want to navigate the content of text field from one class to another and viceversa through button but when I am getting the text from first class I am getting null value.please help me..here is the code
textfield selected text
textfield selected text  How to select text in text field
JavaScript Alert YES NO
JavaScript Alert YES NO  How to send an alert to a user to confirm if there request is valid or not? I wants to send the alert message in Java Script... type="text/javascript"> function show_alert(my_string) { alert(my_string
Alert in Servlet
Alert in Servlet  <p>Hi</p> <p>I want to delete record from oracle db, i need alert message saying 'Are you sure you want... of each row, when i click delete it shd alert me....This is my servlet code:<
how to set the value of textfield constant
how to set the value of textfield constant  how to set the value of textfield constant
IPhone-UIPicker Data to TextField
IPhone-UIPicker Data to TextField  When I select the textfield, a picker view must come in form of action sheet and the data selected from that picker view must be populated in the text field. can anyone help me on this please
alert for validation
alert for validation  i want to put alert on the text box that enter...) if (cpos1==-1 || cpos2==-1){ alert("The date format must be : dd/mm/yyyy... || pmonth<1 || pmonth>12){ alert("Enter a valid month") return
get textfield value in javascript
get textfield value in javascript  How to get and the set value of text field in JavaScript?   Get the text field value in JavaScript <html> <head> <script type="text/javascript"> <
ModuleNotFoundError: No module named 'textfield-parser'
ModuleNotFoundError: No module named 'textfield-parser'  Hi, My... named 'textfield-parser' How to remove the ModuleNotFoundError: No module named 'textfield-parser' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'textfield-parser'
ModuleNotFoundError: No module named 'textfield-parser'  Hi, My... named 'textfield-parser' How to remove the ModuleNotFoundError: No module named 'textfield-parser' error? Thanks   Hi, In your
JSP Alert
;AlertMessage.jsp". The Alert Message contains the code for User Login page that include... the Login Name, an alert box displays showing error message: If you will not enter the Password, an alert box displays showing error message: If you will enter
Information Save Alert
Information Save Alert  Hi, Sir I am creating a web page there user can edit their information. I want a javascript that can show an alert message when user edit the information and trying to close or go to another page without

Ads