Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JavaScriptQuestions How to check for Empty textboxed and fill it with a value on a button click
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Rakesh Keerthi
How to check for Empty textboxed and fill it with a value on a button click
1 Answer(s)      2 years and 3 months ago
Posted in : JavaScript Questions


Hi , i am making a project where there will be a text box with a Button beside it . when i enter a text in that box and click the button it should go of from the first text box and should be added to the target text box and sit should check if it is empty and should get added to the second target text box. the button should be disabled once i click it(i managed to do that), but when i'm trying to enter the text it is getting updated in the second target text box leaving the first blank, could you please help me out with this for all the target boxes, also forgot to mention the target textboxes are to be in read only mode. below is the code

<html>
<head>
<script type="text/javascript">
function move(){
    if(document.getElementById('tgt1').length==0)
{
 document.getElementById('tgt1').value = document.getElementById('Allocation').value;
}
else if(document.getElementById("tgt1").length!=0)
{
    document.getElementById('tgt2').value = document.getElementById('Allocation').value;
}
document.getElementById("Send").disabled=true;
}
function UnBlock()
{
    document.getElementById("tgt1").value="";
    document.getElementById("Send").disabled=false;
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
body {
    margin-top: 20px;
    margin-left: 30px;

}
</style>
</head>
<body>
<form name="myform">
<input type="text" name="Allocation" size="100" align="middle"> 
<input type="button" value="Allocate" id="Send" name="submit" onClick="move()"/><br/>
<br/><br/><br/><br/><br/><br/>
<table>
<tr>
<input type="text" id="tgt1" size="100"><td><input type="button" value="unlinkme" onclick="UnBlock()"</td>
<br/>
<input type="text" id="tgt2" size="100" >
<br/>
<input type="text" id="tgt3" size="100" readonly="true">
<br/>
<input type="text" id="tgt4" size="100" readonly="true">
<br/>
<input type="text" id="tgt5" size="100" readonly="true">
<br/>
<input type="text" id="tgt6" size="100" readonly="true">
<br/>
<input type="text" id="tgt7" size="100" readonly="true">
<br/>
<input type="text" id="tgt8" size="100" readonly="true">
<br/>
<input type="text" id="tgt9" size="100" readonly="true">
<br/>
<input type="text" id="tgt10" size="100" readonly="true">
<br/>
</form>
</body>
</html>

Thanks, Rakesh


Advertisement
View Answers

July 5, 2012 at 3:46 PM


Here is a code which check for Empty textbox and fill it with a value on a button click. When you enter a text in a textbox and click the button, it will get added to the target text box and check if second target box is empty. If it is empty, value will get added to the second target text box. The button will get disabled once you click it.

<html>
<script>
function dis(){
var v=document.getElementById("txt").value;
document.getElementById("txt1").value=v;
document.getElementById('txt1').readOnly=true;
var mystring=document.getElementById('txt2').value; 

if(!mystring.match(/\S/)){
document.getElementById("txt2").value=document.getElementById("txt1").value;
document.getElementById('txt2').readOnly=true;
}
document.getElementById("b").disabled=true;
}

</script>
<pre>
<input type="text" name="txt" id="txt">
<input type="button" id="b" value="Allocate" onclick="dis();">
Target Textbox1: <input type="text" id="txt1">
Target Textbox2: <input type="text" id="txt2">
</pre>
</html>


Related Tutorials/Questions & Answers:
How to check for Empty textboxed and fill it with a value on a button click
How to check for Empty textboxed and fill it with a value on a button... is a code which check for Empty textbox and fill it with a value on a button... with a Button beside it . when i enter a text in that box and click the button it should go
Check if the directory is empty or not
Check if the directory is empty or not In this section, you will learn how to check if the directory is empty or not. Java IO package works with both files and directories. Here we are going to check whether directory is empty
Advertisements
get a radio button click value - JSP-Servlet
get a radio button click value  thanks sir for sending code ,but i have one probs that is i m getting a null value i m calling getParameter("id... in the input tag name="radio" eventhough i m getting a null value please help me
check radio button on retrieving the value from database.
check radio button on retrieving the value from database.  HI i am... database and according to that i want to check the cash cheque radio button... information from database the i want to show cash radio button checked.How can i do
How to call java method on Button click in jsp?
How to call java method on Button click in jsp?  How to call java method on Button click in jsp
how to check the radio button automatically depending up on the value of database when editing the form...
how to check the radio button automatically depending up on the value... to highlight the radio button from the database.......nd even list box also can any... button. When the user clicks the particular radio button, that data will get shown
click on check box
click on check box  I create a check box in HTML and when i click on my check box relative information in page store in database
Check Empty String
Check Empty String      ...): This method is used to check whether a string is not empty (""), not null... a string for its empty (" ) or null value.  The code of the program
passing values on button click
passing values on button click  Please help me to solve this issue.I want to pass a value assigned to button to another view upon button click in xcode
how to remove spell check in flex when button is clicked
how to remove spell check in flex when button is clicked  how to remove spell check when button is clicked in rich text editor control
on click button php
on click button php  Function in PHP for on click button
iphone button click event
iphone button click event  Hi, How to write iphone button click event? Thanks   Hi, Here the method declaration: -(IBAction) myMetod...{ NSLog(@"Button clicked"); } Thanks
jquery button click
jquery button click  jquery button click - I have created a button in JQuery but the problem is that it's not detecting click. What could...; <input id="Button1" type="button" value="button" />
How to hide and show some field on a radio button click
How to hide and show some field on a radio button click  This is my... TYPE=radio NAME="payment_method" VALUE="cash" CHECKED><b class="label">..._method" VALUE="cheque" onclick="return payment();"><b class="label">
Show text field & check input using jQuery
will discuss about how to display 'text field' by a button click & check... how to display 'text field' by a button click & check input using jQuery. In the below example, a button is given when we click on it, 
How to fill double array in java
How to fill double array in java  how to fill double array in java
how to check particular value is avilable in hashmap - Java Beginners
how to check particular value is avilable in hashmap  Hi friends, i created a hashmap,in that hashmap key is tagginglist and value is tagsname,these tags is in the form arraylist.then how i will check particular tags
How to Display next Record from Database "On the Click of Next Button" USING ARRAYLIST
How to Display next Record from Database "On the Click of Next Button" USING ARRAYLIST  How to Display next Record from Database "On the Click of Next Button" USING ARRAYLIST,please send answer as soo as possible
JFrame Button click to start play
JFrame Button click to start play  i made a game and and i add a button in new jframe and i want when i click it it start to play...can anyone help me
java swing button click event
java swing button click event  java swing button click event   public void doClick()   Java Swing Tutorials
On Click on Submit Button Display Data on Orderlist
On Click on Submit Button Display Data on Orderlist  How can retreive data from database on orderlist on Click on submit Button of same page
executing multiple sql statements on the single button click...
executing multiple sql statements on the single button click...  how can i frame a code on the click of a button to insert data into a table as well as to retrieve records from the same table in another form
executing multiple sql statements on the single button click...
executing multiple sql statements on the single button click...  how can i frame a code on the click of a button to insert data into a table as well as to retrieve records from the same table in another form
Moving Div by button click using animate effect
Moving Div by button click using animate effect In this tutorial , we will discuss how to move 'div' left-right by button click using jQuery. In this example , 'div' is moving left / right by left / right button click
How to make the single click as double click in java
How to make the single click as double click in java  How to make the single click as double click in java... By clicking on a tab, the tab should respond as clicked twice i.e (double click on the tab/button)... Its very urgent
JSP view detail page on accept button click
JSP view detail page on accept button click  i Have 1 jsp page in that there r 2 button accept and view details when we click on aceept button it will submit to next page and when click on view details page it will shown the data
How to show next question from database on the click of next button..(Struts & Hibernate)
How to show next question from database on the click of next button..(Struts.... Problem.: When m clicking my next button it is not showing another question...?pageName=2&iid=<%=Id%>"><img src="images/edit-icon.png" title="Click
How to show next question from database on the click of next button..(Struts & Hibernate)
How to show next question from database on the click of next button..(Struts.... Problem.: When m clicking my next button it is not showing another question...="images/edit-icon.png" title="Click Here To Update This Lists" alt="Click Here
How to Display next Record from Database "On the Click of Next Button" USING ARRAYLIST
How to Display next Record from Database "On the Click of Next Button" USING ARRAYLIST  In this code how i will use arraylist(which store all my records in index form) to show next data on button click,so that it will goes
How to Display next Record from Database "On the Click of Next Button" USING ARRAYLIST
How to Display next Record from Database "On the Click of Next Button" USING ARRAYLIST  In this code how i will use arraylist(which store all my records in index form) to show next data on button click,so that it will goes
Draw a line in a JPanel with button click in Java
Draw a line in a JPanel with button click in Java  Draw a line in a JPanel with button click in Java
Advertisements
 

 

 

DMCA.com