• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Need Help With Dynamic text box in JSP

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hai friends
iam new to jsp .i created a wepage in jsp.Can any one help me to solve my problem.That's i need to create dynamic textboxes in jsp and want to display the values of the textbox in next page.As i am new to this i will be thankful if you give me the detailed codes or complete codes.Thanks in advance for your help.
[/color]
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please remember CodeRanch is NotACodeMill. Can you please TellTheDetails? Its very difficult to help otherwise.
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is a "dynamic textbox"?
 
vishnu raj
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Sturrock wrote:Please remember CodeRanch is NotACodeMill. Can you please TellTheDetails? Its very difficult to help otherwise.



Hi paul
Firstof all thanks for your reply.here i am creating a medical website to store the medicines stocks and for billing.Now my problem is i have to create a jsp page in which i can add or remove textboxes.
for example if i add five textboxes to my page i want to get the datas of the textboxes in next page.i tried lot to do this.but i cant finish doing this.please help to do this.
Again thanks a lot for your reply and thanks in advance for your better codings.
 
vishnu raj
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:What is a "dynamic textbox"?


hai bear bibeault
i mean to say add or remove textbox in jsp page and get the data of textbox in next page.
 
Ranch Hand
Posts: 544
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
On a rendered HTML if you need to add textboxes dynamically then you will need to use Javascript. Have a look at jQuery.
Once you are done adding the textboxes you will need to figure out how you are going to send the user entries back to the Server(Might be a servlet).

Regards,
amit
 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can easily do that using innerHtml in JS
 
Goutam Chowdhury
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try with this

<input type="hidden" value="0" id="theValue" />

<p><input type='button' onclick='addInputBox()' value='Add'/></p>

<div id="myDiv"> </div>
<script>
function addInputBox() {

var ni = document.getElementById('myDiv');

var numi = document.getElementById('theValue');

var num = (document.getElementById('theValue').value -1)+ 2;

numi.value = num;

var newdiv = document.createElement('div');

var divIdName = 'my'+num+'Div';

newdiv.setAttribute('id',divIdName);

newdiv.innerHTML = "<input type=\"text\" /> <input type=\"button\" onclick=\"removeInputBox(\'"+divIdName+"\')\" value='Remove'/>"+divIdName;

ni.appendChild(newdiv);

}

function removeInputBox(divNum) {


var d = document.getElementById('myDiv');

var olddiv = document.getElementById(divNum);

d.removeChild(olddiv);

}
</script>
 
vishnu raj
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Goutam Chowdhury really very thanks now i can easily add or remove textbox in my webpage.But please help me how to get the datas of textbox in next page.Thanks in advance for your help
 
Goutam Chowdhury
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi vishnu,
You can get value in your JSP ....

###################################################

<html>
<head>
<title>Multiple Text area Validation</title>
<script>
function addInputBox() {

var ni = document.getElementById('myDiv');

var numi = document.getElementById('theValue');

var num = parseInt(document.getElementById('theValue').value) +1;

numi.value = num;

var newdiv = document.createElement('div');

var divIdName = 'my'+num+'Div';

newdiv.setAttribute('id',divIdName);

newdiv.innerHTML = "<input type=\"text\" name=\"txtArea\" /> <input type=\"button\" onclick=\"removeInputBox(\'"+divIdName+"\')\" value='Remove'/>"+divIdName;

ni.appendChild(newdiv);

}

function removeInputBox(divNum) {

//alert();
var d = document.getElementById('myDiv');
var numi = document.getElementById('theValue');
var num = document.getElementById('theValue').value -1;
numi.value = num;
var olddiv = document.getElementById(divNum);

d.removeChild(olddiv);

}

function check(){
var form = document.forms[0];
var txtS = form["txtArea"];
var len = txtS.length;

if(0 == len){

alert("Please Add boxes");

}else{
for(i=0;i<len;i++)
{
alert(txtS[i].value);

}
}
return true;
}

</script>
</head>
<body>

<form name="myForm">
<p><input type='button' onclick='addInputBox()' value='Add'/></p>
<p><input type='button' onclick='check()' value='InputBoxValue'/></p>
<input type="hidden" name="myvar" value="0" id="theValue" />

<div id="myDiv"> </div>
</form>
</body>
</html>


########################################################################

If you want to get it in JAVA file then you can change like this


<html>
<head>
<title>Multiple Text area Validation</title>
<script>
function addInputBox() {

var ni = document.getElementById('myDiv');

var numi = document.myForm.inputboxlength;

var num = parseInt(numi.value) +1;

numi.value = num;

var newdiv = document.createElement('div');

var divIdName = 'my'+num+'Div';

newdiv.setAttribute('id',divIdName);

newdiv.innerHTML = "<input type=\"text\" name=\"txtArea"+num +"\" /> <input type=\"button\" onclick=\"removeInputBox(\'"+divIdName+"\')\" value='Remove'/>"+divIdName;

ni.appendChild(newdiv);

}

function removeInputBox(divNum) {

//alert();
var d = document.getElementById('myDiv');
var numi = document.myForm.inputboxlength;
var num = parseInt(numi) -1;
numi.value = num;
var olddiv = document.getElementById(divNum);
d.removeChild(olddiv);

}




</script>
</head>
<body>

<form name="myForm">
<p><input type='button' onclick='addInputBox()' value='Add'/></p>
<p><input type='button' onclick='check()' value='InputBoxValue'/></p>
<input type="hidden" name="inputboxlength" value="0" />

<div id="myDiv"> </div>
</form>
</body>
</html>

You can get in the Java file

int length= Integer.valueOf( request.getParameter("inputboxlength")).intValue();
for(int i=1;i<length;i++)
{
s.o.p(request.getParameter("textArea"+i));
}
##############################################################
Thanks
 
vishnu raj
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Goutam Chowdhury,
Thanks for your reply.
Goutham as per your code for jsp i get output as same as before.To add and remove textbox.The only difference is i get a new textbox as "InputBoxValue".On clicking this button it shows 'error on page' at the bottom of page.Kindly help.Thanks in advance for the same.
Vishnu
 
Goutam Chowdhury
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I put the button to alert value inside the text box.
you an remove below line
<p><input type='button' onclick='check()' value='InputBoxValue'/></p>........

After that you will not get any error........By the way the error was coming because I removed check() function from script.....



good luck

thanks
 
vishnu raj
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Goutam Chowdhury wrote:Hi,
I put the button to alert value inside the text box.
you an remove below line
<p><input type='button' onclick='check()' value='InputBoxValue'/></p>........

Hi Gotham
As per your comment i removed "<p><input type='button' onclick='check()' value='InputBoxValue'/></p>........" from the codings .Now there is no error.But Goutham i want to retrive the datas entered in textbox in the next page.Kindly help in doing this.
Thanks in advance

Vishnu

 
Goutam Chowdhury
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Vishnu,
As a told you early ......

See you need to understand the logic......how I created the input boxes....

Everytime I am creating a box I am giving a name
newdiv.innerHTML = "<input type=\"text\" name=\"txtArea"+num +"\" /> <input type=\"button\" onclick=\"removeInputBox(\'"+divIdName+"\')\" value='Remove'/>"+divIdName;

Here name of the boxes txtArea1,txtArea2,txtArea3....so on

so If you want to get it in the next resource(servlet or JSP) you need to use "request" object

the way we do is
int length= Integer.valueOf( request.getParameter("inputboxlength")).intValue();
for(int i=1;i<length;i++)
{
s.o.p(request.getParameter("textArea"+i));
}


here "inputboxlength" is the number of input boxes....

In the next resources (servlet or JSP) you need to execute the above logic..

Best of luck
 
vishnu raj
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Goutam
Really very thanks to you.Its working good and Iam sorry to disturb you again and again.
But let it be my last doubt and clarification.
1.As per your codings i get the value of textbox in nextpage.But if i add two textbox i get the value of firsttextbox only in nextpage.
2.After adding two textbox and if i go back to that page and while clicking add box for adding moretextbox it appears as textbox-3 ,textbox-4 ... . But i dont want this.I want same as Textbox-1,Textbox-2.
3.for example Java,Javax is my data for 3 and 4 textbox.In the next page while retriving the values it shows "null null Java".The data of 4th textbox is not appearing.HOPE YOU UNDERSTAND MY PROBLEM.
4.Then after adding 5,6,7,8,9 textboxes, if i delete 7th and 8th textbox and after clicking submit button to retrive values it shows error in the page.My assumption is we can retrive datas only for contionus textbox numbers not for uncontionoues.(1,3,6,7,9).
Gowtham this my another help i need from you
i want to add three textbox at single time and retrive its data in nextpage.Is it possible.

Kindly help for the above and Thanks in advance for the same.
 
Goutam Chowdhury
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Vishnu,
I am glad to help you.

Now I tested in my Tomcat server......


I created two jsp.
1st one is for creating and putting value
2nd one is dispalying and one link to add more element;


JSP 1
##############################################################################################

<html>
<head>
<title>Multiple Text area Validation</title>
<script>
function addInputBox() {

var ni = document.getElementById('myDiv');

var numi = document.myForm.inputboxlength;

var num = parseInt(numi.value) +1;
//alert(num);
numi.value = num;

var newdiv = document.createElement('div');

var divIdName = 'my'+num+'Div';

newdiv.setAttribute('id',divIdName);

newdiv.innerHTML = "<input type=\"text\" name=\"txtArea"+num +"\" /> <input type=\"button\" onclick=\"removeInputBox(\'"+divIdName+"\')\" value='Remove'/>"+divIdName;

ni.appendChild(newdiv);

}

function removeInputBox(divNum) {

//alert();
var d = document.getElementById('myDiv');
var numi = document.myForm.inputboxlength;
//alert("current value inputboxlength="+numi.value);
var num = parseInt(numi.value) -1;

numi.value = num;
var olddiv = document.getElementById(divNum);
d.removeChild(olddiv);
//alert("after removing value inputboxlength="+num);

}


function reset()
{
var numi = document.myForm.inputboxlength;
numi.value=0;
//alert("current value inputboxlength="+numi.value);
}

</script>
</head>
<body onload="reset()">

<form name="myForm" action="result.jsp" >
<p><input type='button' onclick='addInputBox()' value='Add'/></p>
<input type="hidden" name="inputboxlength" value="0" />
<div id="myDiv"> </div>

<input type="submit" value="ShowValue" >
</form>

</body>
</html>

##########################################################################################
<%@page import="java.util.*" %>
<%
int length= Integer.valueOf( request.getParameter("inputboxlength")).intValue();
for(int i=1;i<=length;i++)
{

if(request.getParameter("txtArea"+i)!=null){%>

<%=request.getParameter("txtArea"+i) %>
<%}
}

%>

<form name="resultForm" action="final.jsp" >
<input type="submit" value="AddAgain" >
</form>

#########################################################################

Waiting for your reply
Thanks
 
vishnu raj
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hai Gautham
Really very thanks to you.Because for each and every doubts what i had is cleared by you as like good teacher.Really thanks Gautham.Now as a student let me clarify something
1.Gautham is it possible to get 3 textbox in page side by side.For example
we have three textboxes named as a,b,c.Now i want my textbox in such a way

A B C
ie.while click the add button i want three text box side by side.Hope you understand.
2.i worked your code in Tomcat Server.This is what i expected and thanks for it.
But I added three textboxes 1,2,3.I entered datas like
1.Java
2.Javax
3.Html
Now i deleted 2nd textbox.So that Java and Html should displayed in result.jsp.But only Java is displayed.

Gautham please let me know the details for the above and thanks in advance for the same.
 
Goutam Chowdhury
Ranch Hand
Posts: 44
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Ans 1>
Modify the result.jsp

<%@page import="java.util.*" %>
<%
int length= Integer.valueOf( request.getParameter("inputboxlength")).intValue();
for(int i=1;i<=length;i++)
{

if(request.getParameter("txtArea"+i)!=null){%>
<%=request.getParameter("txtArea"+i) %>
<%}else
{
length=length+1;
}
}

%>

<form name="resultForm" action="final.jsp" >
<input type="submit" value="AddAgain" >
</form>

###########################################################################

Ans 2>YES it possible

add3Box.jsp


<html>
<head>
<title>Multiple Text area Validation</title>
<script>
function addInputBox() {

var ni = document.getElementById('myDiv');

var numi = document.myForm.inputboxlength;
var num=numi.value;

var inputdiv = document.myForm.inputdivlength;

var inputdivLen = parseInt(inputdiv.value) +1;
//alert(num);

var newdiv = document.createElement('div');

var divIdName = 'my'+inputdivLen+'Div';

newdiv.setAttribute('id',divIdName);

newdiv.innerHTML = "<input type=\"text\" name=\"txtArea"+(num=parseInt(num)+1) +"\" /> <input type=\"text\" name=\"txtArea"+(num=parseInt(num)+1) +"\" /><input type=\"text\" name=\"txtArea"+(num=parseInt(num)+1) +"\" /> <input type=\"button\" onclick=\"removeInputBox(\'"+divIdName+"\')\" value='Remove'/>"+divIdName;

ni.appendChild(newdiv);
numi.value = num;
inputdiv.value=inputdivLen;
//alert(num);
}

function removeInputBox(divNum) {

//alert();
var d = document.getElementById('myDiv');
var numi = document.myForm.inputboxlength;
//alert("current value inputboxlength="+numi.value);
var num = parseInt(numi.value) -3;

numi.value = num;
var olddiv = document.getElementById(divNum);
d.removeChild(olddiv);
//alert("after removing value inputboxlength="+num);
//alert(num);
}


function reset()
{
document.myForm.inputboxlength.value=0;
document.myForm.inputdivlength.value=0;
//alert("current value inputboxlength="+numi.value);
}

</script>
</head>
<body onload="reset()">

<form name="myForm" action="result.jsp" >
<p><input type='button' onclick='addInputBox()' value='Add'/></p>
<input type="hidden" name="inputboxlength" value="0" />
<input type="hidden" name="inputdivlength" value="0" />
<div id="myDiv"> </div>

<input type="submit" value="ShowValue" >
</form>

</body>
</html>

###################################################
In the result.jsp just change is line

<form name="resultForm" action="add3Box.jsp" >

Thanks
Goutam
 
vishnu raj
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Goutham
This is what i expected .Really thanks.
Gautham why the loading for result.jsp is too late.Not even too late it doesent open.But there is no error.The page is loading so on(tooooo late).Why this happens.?
Then Gautham i know to add two textbox numbers using Javascript.But i get the values in next page only .Is there way to get in same page.
For example:
Textbox1 | Textbox2 | Textbox3
12 | 3 | ?(can i get answer here)



Again Goutham look below for my databse


id | Medicinename | Qty
1 | a | 9
2 | b | 50
3 | c | 2
4 | a | 50
here the medicinename "a" comes in id 1 and 4.(This is for example only.I dont know exactly the number.It may changes during my updation.)
My problem is i want to display the qty of medicinename "a".Whenever the qty for particular name is "0" i want to display the next id in that particular medicinename. Hope you understand.

Below is my code to fetch the datas from database


<%@ page import="java.sql.*"%>
<%
String medicinename=request.getParameter("medicinename");
String combinationname=request.getParameter("combinationname");

Connection conn=null;
Statement stm =null ;
ResultSet rs=null;
String query=null;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn=DriverManager.getConnection("jdbc:odbc:medicine");
stm = conn.createStatement();

query="SELECT * FROM medicine1 WHERE medicinename='"+medicinename+"' OR combinationname= '"+combinationname+"' ";
rs= stm.executeQuery(query);
while (rs.next())

{


%><table border="1" width=300 height=2><td><%
out.println(rs.getString(1));
%> </td><%

%><td><Testox2><%
out.println(rs.getString(2));
%> </td></TestBox2><%
%><td><%
out.println(rs.getString(3));
%> </td><%
%><td><%
out.println(rs.getString(4));
%> </td><%
%><td><%
out.println(rs.getString(5));
%> </td><%
%><td><%
out.println(rs.getString(6));
%> </td><%
%><td><%
out.println(rs.getString(7));
%> </td><%
%><td><font color="#FF0000"><%
out.println(rs.getString(8));
%> </td><%
%><td><%
out.println(rs.getString(9));
%> </td><%
%><td><%
out.println(rs.getString(10));
%> </td><%
%><td><%
out.println(rs.getString(11));
%> </td></table><%

}
stm.close();
conn.close();
}
catch (Exception e)
{
out.println(e.toString());
}
%>


Here is the code i am using to fetch datas from database.
Again Gautham let me expalin what i want to do

id Medicinename Qty
1 a 9
2 b 50
3 c 2
4 a 50

If the qty of medicine name "a" is 0 in id 1,i need the request.parameter to fetch the data automatically from id "4".But the id is only for example.the id may varies.

Goutham help me to know how to work on this.

Thanks in advance for same.
Vishnu
 
Bear Bibeault
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please UseCodeTags.
 
Goutam Chowdhury
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
1> For me its working fast...check your code
2> In Java script we can add two int put box value and show in the same page using inner html
3> what do you mean by "combinationname"

whatever



Thanks
 
vishnu raj
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Goutam Chowdhury
Sorry there is a small error in my code and now i rectified this and now its working fast.Also i completed the code in javascript for sum of two numbers.
Gotham please help me in doing the following
1. We get multiple textbox datas in next page.Now i have to get the paricular details of each textbox data from database.i know to work for retriving single data.
for example let me tell you briefly.
For medical billing system while enetering the name of medicine in textbox i have to retrive the datas from database without refreshing the page.
Below is the code i am using to retrive datas from database for single stringname.


<%@ page import="java.sql.*"%>
<%
String medicinename=request.getParameter("medicinename");

Connection conn=null;
Statement stm =null ;
ResultSet rs=null;
String query=null;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn=DriverManager.getConnection("jdbc:odbc:medicine");
stm = conn.createStatement();

query="SELECT * FROM medicine1 WHERE medicinename='"+medicinename+" ' ";
rs= stm.executeQuery(query);
while (rs.next())

{


%><table border="1" width=300 height=2><td><%
out.println(rs.getString(1));
%> </td><%

%><td><Testox2><%
out.println(rs.getString(2));
%> </td></TestBox2><%
%</td></table><%

}
stm.close();
conn.close();
}
catch (Exception e)
{
out.println(e.toString());
}
%>

by using this code we can get datas only in next page.Also for only one textbox data we can use this.
I want to get datas from database for multiple textbox(by using the above codes given by you i can add more textbox)in samepage.if i entered the name of medicine in textbox i should get the datas from database immediately for the particular medicine without refreshing the page.
Hope you understand.

Gotham please help me in doing this and Thanks in advance for same.
Vishnu
 
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Vishnu,
Please UseCodeTags while posting code in the forums (as already pointed out by Bear).

... i have to retrive the datas from database without refreshing the page...


For this you need to use AJAX which is capable of sending asynchronous requests to the server. And using Java code inside JSP is considered a bad practice, instead you should use EL, JSTL, Standard/Custom actions for data manipulations in JSP. And move the business logic in to Servlet/POJOs etc...

You can re-factor the code by moving the data access code to a POJO and then have a servlet talk to that POJO (logic in this POJO also can be separated to different layers of the application such as DAO layer etc...). From JSP you should send the AJAX request to that servlet which then retrieve the required data through the POJO which holds the business logic. Then you can display the returned data as you wish. You may need to read more on AJAX to see how to send/process the request/response.
 
Goutam Chowdhury
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Vishnu,
1> If you want to display required data from database without refreshing the page then you need to do a Ajax call..
Take any simple example and try to implement........
2>While doing any Ajax call we can send multiple text box values as request parameter .Get those parameters in the resource(jsp or servlet) which one you mention while calling Ajax.

After that fire the query and get the data .......

As a result of your call you wil get a "xmlHttpReq.responseText".

You should create a blank div in your page and after getting the response you need to display same in that div..
like
webpage

Thanks


 
vishnu raj
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Gotham
As per your advice i just tried with ajax.
Now i tried to create a combo box in which if i selected a medicinename (by dropdown-heredatas will be fetched from database)the balance two details of that medicine will be automatically displayed in the other two textboxes.(the details like Batchnumber,combinationname.The details fetched from database).
What my problem is the medicine name name comes correctly but the combinationname and batchnumber does not comes correctly.Itmeans its not displaying.i think there is some error in my code.
Gotham as already said iam new to jsp and very new to ajax please help me with sample codes to work on this and thanks in advance for same.

With regards
Vishnu
 
Goutam Chowdhury
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am not clear with your requirement.
If you want you can send your whole code and DB table details.....
Otherwise you can send dummy html and DB details

Thanks
 
vishnu raj
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Goutham
I am trying to create a billing section for medical shop.I used jsp codes to store the details like invoice details,purchase details and etc.Now my final step is to do billing section and i tried alot to do.But i cant.Typically what i want is
1.if a customer want some medicines i used the codes given by you to add or delte textbox in which i can enter medicines.


As per the code given by you i can add or remove three textboxes (side by side).

2.Say for example a customer needs three type of medicines.And i add three text box(as per your code)if i enter the name of medicine i want to get batchnumber,expirydate,rate/unit side by side.
Please save this in your html page to see clearly for my requriements
Name.index.html


*Qty is enter the quantity of medicines.
*When i entered medicine name i want to get Batchnumber,Expirydate,Rate/unit
in the particular textbox(Also note here i will use the code given by you to add
or remove textbox)
*In the Total textbox i want to get the the value of (qty *Rate/unit)
* in the Grand Toatl i want sum  of Total textbox.


As per your comments i tried a example by using ajax.i can get only the medicinename from database
Below is the code for ajax
Name:textbox.jsp



Another continous page for this is
Name:value.jsp

Below is my sample database table for your reference.
Database Name:Medicine1



Goutham i tried some thing in ajax to get the names.Also look my database.There are lot of medicines in same name.While billing if the balance stock(in database)is "0" i want the request parameter to pass for the next medicine in same name.

Hope every thing is now clear to you and this is my final stage to compelte my project.Now i need your help to compelte this with codes.
Thanks in advance for your kind support.
Vishnu



 
Goutam Chowdhury
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Vishnu,
Now your coding part is over.But it is not working.Means there is something wrong.So you need to debug it.

1.
You are telling if balancestock =0 then you need take next one.......but it is not clear ...balancestock is greter than 0 ,may be multiple rows.....so how you can do is....you fire one query and sort the result stockat rate ASC..then we will take first row
This need to change

balancestock is Integer I guess.
My suggestion is execute this query in the database directly.
It should work fine.

2.Then Instead of

Put this


and print the buffer value....
If it is printing fine then you need to look into your textBox.jsp


First try with this...
Later I will send you whole modified code



 
vishnu raj
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Goutham
Thanks for your reply.Let me try with your code.Also waiting for code.
Thaks in advance for same.
Vishnu.
 
vishnu raj
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Goutahm
Regaring codes iam waiting for your reply.
Vishnu
 
I need a new interior decorator. This tiny ad just painted every room in my house purple.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic