Flash Games

 FAQ   Search   Members   Groups   Register  User Control Panel      Login 

Your time now:
Sat Nov 21, 2009 9:56 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 12 posts ]  Bookmark and Share
Author Message
 Post subject: How to display data in textbox
PostPosted: Tue Nov 25, 2008 2:28 pm 
Offline

Joined: Tue Nov 25, 2008 2:25 pm
Posts: 6
I want to fetch data from mysql and display in textbox when I click the corresponding item in listbox. I used SQL JSTL to fetch data for listbox. Please help me how to display data in textbox?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 26, 2008 3:02 am 
Offline
500+ Club
User avatar

Joined: Wed Feb 27, 2008 6:14 am
Posts: 929
Location: Cebu City Philippines
You can use the value method available on the textbox element.

Please show us the generated markup of your listbox (select element) so we could help you have a script of your desire.

_________________
~ Get me some work, I do freelancing ~


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 26, 2008 7:09 am 
Offline

Joined: Tue Nov 25, 2008 2:25 pm
Posts: 6
My listbox has some product names
LG
Sanyo
like this
When I click LG item in listbox corresponding data should be displayed in the textbox

I tried

<input style="WIDTH: 83px; HEIGHT: 23px" size="10" name="Quantity">
<c:forEach var="row" items="${list.rows}">
<c:set var="quantity ">"{row.quantity }"
</c:set>
<option>
<c:out value="{row.quantity }"/>
</option>
</c:forEach>

All datas are displayed.But I want to display one data. Please help me


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 26, 2008 8:12 am 
Offline
500+ Club
User avatar

Joined: Wed Feb 27, 2008 6:14 am
Posts: 929
Location: Cebu City Philippines
Please show the generated markup.

The one that you see when you view the source.

_________________
~ Get me some work, I do freelancing ~


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 26, 2008 10:02 am 
Offline

Joined: Tue Nov 25, 2008 2:25 pm
Posts: 6
I am not getting what you are asking

I used

<sql:query var="list" dataSource="${dataSource}">
select user_id,name,sum(quantity) as quantity from Product GROUP BY name;
</sql:query>

I have Name Listbox and quantity textbox

The values are displayed as 200,400,800..outside the textbox

I want to display the corresponding value in the textbox when I click the name in the listbox

Please help


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 26, 2008 10:09 am 
Offline
500+ Club
User avatar

Joined: Wed Feb 27, 2008 6:14 am
Posts: 929
Location: Cebu City Philippines
The code you're showing is a server-side script (or better yet a raw file).

I'm asking for the generated markup.

The one you see when you view the page's source.

Hope that makes sense.

_________________
~ Get me some work, I do freelancing ~


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 26, 2008 10:23 am 
Offline

Joined: Tue Nov 25, 2008 2:25 pm
Posts: 6
<table cellspacing="0" cellpadding="3" width="40%" align="left" border="0">

<tr>
<td>&nbsp; Stock Code</td>
<td><select size="1" name="name">

<option>
LG
</option>


<option>
Samsung
</option>


<option>
Sony
</option>




</select></td></tr>
<tr>
<td>&nbsp; Quantity</td>
<td><input style="WIDTH: 83px; HEIGHT: 23px" size="10" name="Quantity">



<option>
20200
</option>



<option>
12000
</option>



<option>
200
</option>





</td>
</tr>


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 26, 2008 10:32 am 
Offline
500+ Club
User avatar

Joined: Wed Feb 27, 2008 6:14 am
Posts: 929
Location: Cebu City Philippines
I see. You're second select element is erroneous.

You should contain option element inside select element:
Code:
<option>
20200
</option>



<option>
12000
</option>



<option>
200
</option>


Which of the two select element are you wanting its selectedIndex texts be shown on the textbox?

_________________
~ Get me some work, I do freelancing ~


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 26, 2008 10:39 am 
Offline

Joined: Tue Nov 25, 2008 2:25 pm
Posts: 6
I don't want to list all quantity data in the listbox. If I use option inside select ,all values will be listed in the listbox.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 26, 2008 10:52 am 
Offline
500+ Club
User avatar

Joined: Wed Feb 27, 2008 6:14 am
Posts: 929
Location: Cebu City Philippines
That doesn't makes sense.

Anyway, how about a response to my question?

_________________
~ Get me some work, I do freelancing ~


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 26, 2008 1:27 pm 
Offline

Joined: Tue Nov 25, 2008 2:25 pm
Posts: 6
second one quantity value should be displayed in the textbox


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 26, 2008 1:55 pm 
Offline
500+ Club
User avatar

Joined: Wed Feb 27, 2008 6:14 am
Posts: 929
Location: Cebu City Philippines
It doesn't makes sense to me since the second select element isn't a "select" element since you don't want the option element be a child of select element.

Anyway, this might help:
Code:
<script type="text/javascript">
/**
* Copy option's value/text to textbox
* Additional Feature: Be able to instruct the script as to the mode you wish.
* Created by Raymond Angana [username = rangana]
* First seen in devppl.com/forum
* This script must stay intact for legal use
*/
var ray=
{
transfer:function(inp,out,mod)
   {
   this.getID(inp).onchange=function()
      {
         ray.getID(out).value=mod?this.options[this.options.selectedIndex].text:this.value;
      }
   },
getID:function(el)
   {
      return document.getElementById(el); // Get the element's id
   }
}
window.addEventListener?window.addEventListener('load',function()
   {
   /**
   * @param1 - ID of the select element
   * @param2 - ID of the textbox where you want the value be seen
   * @param3 - Mode you wish the script to run. You could choose from 0/1
      0 - Will use the value of the options
      1 - Will use the text of the options
   */
   ray.transfer('myselect','output',1); // Last argument could either be 0/1. If 0, then it will get the options value, if 1, it will get the options texts
   },false):
window.attachEvent('onload',function()
   {
   /**
   * @param1 - ID of the select element
   * @param2 - ID of the textbox where you want the value be seen
   * @param3 - Mode you wish the script to run. You could choose from 0/1
      0 - Will use the value of the options
      1 - Will use the text of the options
   */
   ray.transfer('myselect','output',1); // Last argument could either be 0/1. If 0, then it will get the options value, if 1, it will get the options texts
   }); // FF : IE
</script>
<select id="myselect">
<option value="Opt1">Option 1</option>
<option value="Opt2">Option 2</option>
<option value="Opt3">Option 3</option>
<option value="Opt4">Option 4</option>
<option value="Opt5">Option 5</option>
</select>
<input type="text" readonly="readonly" id="output">


You can change the mode from 0 - 1. Comments explain the purpose.

Default is 0, which gets the options value.

Hope that helps.

_________________
~ Get me some work, I do freelancing ~


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group - Flash Games - TNX Invitation Code - TNX Review


Webmaster - Excruciating - Johnathan - Kotik - Ash - Tomi - rangana - Phate - dflynn - Medley