File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes how to pass this value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "how to pass this value" Watch "how to pass this value" New topic
Author

how to pass this value

nad nadia
Greenhorn

Joined: Mar 20, 2007
Posts: 6
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

Joined: Jan 05, 2007
Posts: 11
let me know waht ia a
srinu reddyreddy
Greenhorn

Joined: Jan 05, 2007
Posts: 11
try this
<INPUT TYPE="button" VALUE="Click Here"
on Click="add(a)">
srinu reddyreddy
Greenhorn

Joined: Jan 05, 2007
Posts: 11
there is no space in onClick
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41508
    
  53
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 ]

Ping & DNS - my free Android networking tools app
nad nadia
Greenhorn

Joined: Mar 20, 2007
Posts: 6
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
Marshal

Joined: Mar 22, 2005
Posts: 41508
    
  53
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

Joined: Mar 20, 2007
Posts: 6
"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
Marshal

Joined: Mar 22, 2005
Posts: 41508
    
  53
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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to pass this value