Submit Your Article Webforumz RegistrationAnnouncements Contact Webforumz StaffContact
Home Resources Blogs Meet the Team Contact Register
 

Go Back   WebForumz.com > The Code > JavaScript

Reply
 
LinkBack (1) Thread Tools
Old May 26th, 2006, 12:15 AM   1 links from elsewhere to this Post. Click to view. #1
New Member
 

Join Date: May 2006
Location: earth
Age: 25
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 melvinoyh is on a distinguished road
Exclamation Getting value from function

for example this function get a value from a textbox and calculate and return the value to another textbox. this example can work.
-------------------------------------
<script type="text/javascript">
function chkBreakdown(){
myForm=document.brk
total=50*myForm.brkID.value
myForm.brk_total.value=total;
}
</script>
<html>
<body>
<form name="brk">
<input type="text" name="brkID" value="0" size="3" maxlength="3" onblur="chkBreakdown()">
<input type="text" name="brk_total">
</form>
</body>
</html>
------------------------------------------
now my problem is for example below:
Vector wp = new Vector();
Vector ln = new Vector();
<script type="text/javascript">
function chkBreakdown(wp,ln,la){
myForm=document.brk
total=wp+ln+la+*myForm.brkID<%=c%>.value <--is this correct or not?
myForm.brk_total.value=total;
}
</script>
<html>
<body>
<form name="brk">
<tr><td>LA no.</td><td>: <input type=text id="laNo" size=6 style="border:0" value='<%=la_no%>'> </td></tr>
<%for(int c=0; c<wp.size(); c++){%>
<td><input type="text" size=5 name="wp<%=c%>" value='<%=wp.elementAt(c)%>'></td>
<td><input type="text" size=4 name="ln<%=c%>" value='<%=ln.elementAt(c)%>'></td>
<td><input type="text" size=8 name="brkID<%=c%>" id="brkID" value='<%=brkID.elementAt(c)%>' onFocus="chkBreakdown('<%=wp.elementAt(c)%>','<%=l n.elementAt(c)%>','<%=la_no%>');"></td>
</form>
<input type="text" name="brk_total">
</body>
</html>
melvinoyh is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old May 26th, 2006, 09:06 AM   #2
Most Reputable Member
 

Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,307
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 ukgeoff has a spectacular aura about ukgeoff has a spectacular aura about
Re: Getting value from function

Code:
function myFunction(...){
   ...
   ...
   ...
   return someValue;
}
The variable someValue needs to hold whatever you wish to return from the called function.

BTW. In your second example above, you define two variable outside the <script>...</script> tags. This is not allowed.
ukgeoff is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old May 26th, 2006, 08:57 PM   #3
New Member
 

Join Date: May 2006
Location: earth
Age: 25
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 melvinoyh is on a distinguished road
Re: Getting value from function

oh in my second example, ya i know, i should write like this
<%!
Vector wp = new Vector();
Vector ln = new Vector();
%>

then how about this sentence of code, izzit correct?
<td><input type="text" size=8 name="brkID<%=c%>" id="brkID" value='<%=brkID.elementAt(c)%>' onFocus="chkBreakdown('<%=wp.elementAt(c)%>','<%=l n.elementAt(c)%>','<%=la_no%>');"></td>

when on focus, then call a function together with 3 parameters.
melvinoyh is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Bookmarks

Tags
getting , value , function


LinkBacks (?)
LinkBack to this Thread: http://webforumz.com/javascript/6542-getting-value-from-function.htm
Posted By For Type Date
Getting a value from a called function - ng.asp-net-forum.getting_started - error problem solve @CodeVerge This thread Refback February 10th, 2009 04:26 AM

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
using the array_unique function eon201 PHP 1 November 12th, 2007 09:54 AM
DateTime Function tanya_1985_am Classic ASP 5 October 12th, 2007 12:42 PM
Mail function alexgeek PHP 4 September 22nd, 2007 08:18 AM
onclick function tomd1985 JavaScript 0 March 13th, 2006 02:20 PM
SQL Function spinal007 Databases 1 March 25th, 2005 05:43 AM


Search Engine Optimization by vBSEO 3.2.0 RC8