• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to pass this value

 
nad nadia
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I really dun know how to pass the a value to the add function, can anyone help me?
while(rs_it.next())
{ a=rs_it.get string("item_type");
i++;}
input type="button" on click="add(a)"/button
script language="JavaScript"
function add(b){
window.alert("a"+b); }
[ March 21, 2007: Message edited by: Bear Bibeault ]
 
srinu reddyreddy
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
let me know waht ia a
 
srinu reddyreddy
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try this
<INPUT TYPE="button" VALUE="Click Here"
on Click="add(a)">
 
srinu reddyreddy
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
there is no space in onClick
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it intentional that you're assigning to "a" multiple times, effectively discarding any but its last value? Try this:

<input type="button" onKlick="add(<%= a %>)">

(the name of the click handler does not have a K, but a C, of course)
[ March 21, 2007: Message edited by: Ulf Dittmer ]
 
nad nadia
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I try already... still cannot... mayb bcoz the value is actually is an array...
the a value have many value like "a,b,c,d,e,f,g........"
THANKS FOR ALL YOUR HELP.. still need more help
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not following: the "rs_it.getstring" method returns an array? It needs to, since you state that "a" is an array. Tell us what kind of datatype "a" is, and what you hope to achieve by adding something to an array. What kind of type is the "b" in the JavaScript code? TellTheDetails
[ March 21, 2007: Message edited by: Ulf Dittmer ]
 
nad nadia
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"a" is an item_type, and its a string..
I try to get record in database, and once i got the result, i need to pass all the data I got to java script.
so the "b" is a "a" its just I dunt know how to pass to JS, in JS i want to popup all the value that i got from JS.
what I want exactly is, how to pass all the record from rs.getString to the javascript function
thnk you
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, now we're getting somewhere. "a" is a string, so I'll ignore what you said earlier about "a" being an array. The following piece of code runs the loop in a JSP page, and then generates a JavaScript handler where the final value of a is hard-coded as a parameter to the function. If the value of a is "a", then the alert should show "ab".


Be advised that it is bad design to have DB code in a JSP - you're much better off doing that in a backing bean. It also seems strange to assign multiple values to "a" in the loop, when apparently all that matters is the last contained in the last record.
[ March 21, 2007: Message edited by: Ulf Dittmer ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic