Storing variable in a hidden field
HI,
I've created an HTML form with drop downs. I'm storing the
values of each option in a variable called currentvalue.
Currentvalue keeps a running total and displays it on the page. I
want to store the variable currentvalue in a hidden field to pass
the value to the next HTML page. How can I do this?
I'm using JavaScript for this application becuse I can't use
any server side code since the application will be distributed on a
CD.
Thanks,
Thanks MikeL7 for your code.
I'm not sure about "var currentvalue = 9;" is that a fixed
value that you've shown as an example?
My currentvalue is a variable that is keeping a running total
of the the values selected from each drop down. I need to capture
the value of this running total into my hidden field that I can
then pass on to page 2.
I hope I'm making sense here.
Thanks,
Similar Messages
-
What is the difference between hidden field and view state??
Both view state and hidden field are use to store page specific information then, what is the difference between both of them??
The ViewState of a page is actually stored in a large hidden field and it contains information about the entire page whereas a single hidden field that you define yourself is used to store some single value that should not be displayed.
Please refer to the following page for more information about ASP.NET View State:
http://msdn.microsoft.com/en-us/library/ms972976.aspx
But please post your ASP.NET and web related questions at
http://forums.asp.net in the future.
Also, please remember to mark any helpful posts as answer. -
Using Hidden Fields as Variables
I am limited in my JavaScript coding abilities. I am building a rather large homeowners insurance application that ultimately computes the premium. There are a ton of options that affect costs and I need a way to store a few numeric values. LC Designer doesn't appear to allow numeric variables (only string variables). As a work around, I have started to setup some hidden numeric fields to store some values and have their values change according to the users actions. I think this is going to work but is inefficient--the PDF ends up containing a lot of information about these hidden fields that is totally irrelevant to the task being asked of them. I thought I should ask a couple of questions before I get too far down the path I am taking.
My question #1: what are the other caveats in doing it this way?
My question #2: is there a better way or work-around that is relatively easy to do? (I am not stupid, but I am not much of a coder either). If someone could provide an example of something that can act like a numeric variable (easily accessed & changed) I would be most grateful.Paul,
I have tried without success using the form properties variables tab for entering variables. There is absolutely no documentation on the specific manner in which this is done, or whether it can accommodate arrays. I mean absolutely no documentation that I can find other than references to the LC feature like: "enter variables in the variables tab of the form properties," period. Great! but tell me more please, like specifically how?
Other than the name of the variable and a value, are there supposed to be:
"var"
"="
syntax needed, you get my drift, I hope.
And, what about arrays? And, does it matter if these values are intended to be numeric?
I think I would prefer to use the variables tab because it centralizes their location, and in some cases I may need to change ones I might use as constants, down the road. This becomes much handier for that.
Stephen -
General practice for storing variable in Web Application
I am working for an enquiry program which across several JSP pages. I need to pass the criteria variable across tha pages.
For general practice, the variable will be stored in the session or as a hidden input.
Or any other better solution.
Please help
regards,
FannieStoring the vars in the session would probably be the way to go. Using hidden fields in your HTML would allow the user to view source and see the vars. Using hidden fields also can be easily spoofed and would be a maintenance nightmare. Depending on you app requirements, I'd have a Criteria object (stored in the session) that encapsulates app criteria gathered.
-
Prefer hidden field instead of session attribute
In my application we have around 17 jsp for getting information
from the user.
Also we have around 65 jsp for user navigation
This 17 jsp has average 19 html components like textbox,
select etc
To maintain user entered data we prefer hidden field than
session attribute.
Number of user: 1, 00,000
Server: WebSphere Application Server v6.1
Framework: struts 1
For every new module in our project we add corresponding
variable in all the forms and there jsp to maintain the user entered data.
I know that this is an extra work and changing the other module
code just to retain the user information is not a good design.
But we believe that putting the struts form in session will
lead to memory out for 1, 00,000 user
Please guide me is this approach right or wrong?
Edited by: WorldOfJava on Jul 17, 2009 6:48 AMHi WorldOfJava,
IMO, it is not a good practice to hide data in forms and to transport them from page to page. It's growing uselessly the size of HTML documents. Also, the servlet which has to treat the user's request will have each time to extract the hidden data in order to fire them to the next servlet.
Just imagine you have to build a web site like Amazon where people can buy products on line, your solution means that the content of the client's basket will be hidden in each page displayed in the client's browser !
The better solution is to use a bean where data may be stored for each session. All you have to do, it's to build a Map that contains the session id (obtained via the getId() method of the [*HttpSession*|http://java.sun.com/products/servlet/2.2/javadoc/javax/servlet/http/HttpSession.html] interface) as a key and the bean as a value. The advantage of such system is when you want to add new modules with new data in your application, you have only to add new instance variables and their getters/setters to the bean. -
Pivot Table - Calculate Variance - Hidden Fields?
I need some help adding a target value field inside a pivot table in excel.
Here is what my current pivot table looks like.
Regions 1 year - Actual 1 year - Target??
Difference
(April 2013 to MArch 2014)
(Target - Actual)?
Region1 $6,355,696.75
Region2 $6,775,309.87
Region3 $2,230,424.76
Regions expand into managers which in turn expand to consultants.
What I want to do is add a column for target values of the 3 different regions and then create another calculated field that will show the difference between the target and actual values.
Can this be done without writing any stored procedures in SQL? I want to do this in excel itself.
The target values are not calculated so can we store them in hidden fields or something in the pivot or excel?1. Click anywhere in Pivot and go to Options tab > Formulas > Calculated Field.
2. Create a calculated field called Target (whatever name your choose). If your target is say 7000000, put this value in Formula field. You may put it with or without =
3. Now after this, you can once again create a new Calculated Field. Let's say this is Variance. If you variance is Target - Actual, put this as =Target-Actual in Calculated Field.
4. Your pivot will have whatever you wanted. -
Hidden field in form returns null value
Hi all - I searched for this but found nothing that fit my problem although various other problems came up.
I have a Login jsp, with a simple form for username and password:
<form name="login" method="post" action="servlet/ControlServlet"
onSubmit="return validateForm()"><table width="180" border="0"
cellspacing="0" cellpadding="0">
<tr>
<td width="96" class="logintext">Username</td>
<td width="84"> </td>
</tr>
<tr>
<td><input name="username" type="text" size="15"
maxlength="15"></td>
<td><input type="submit" name="Submit" value="Login"></td>
</tr>
<tr>
<td class="logintext">Password</td>
<td> </td>
</tr>
<tr>
<td class="logintext"><input name="password" type="password"
size="15" maxlength="15"></td>
<td><input name="actionCode" type="hidden" value="0"></td>
</tr>
<tr>
<td> </td>
<td><div align="center"><a href
="Register.jsp"><i>Register</i></a></div></td>
</tr>
</table>
</form>Nothing complex in that form. my hidden field is actionCode and it should pass a 0 to my ControlServlet servlet.
Here is a snippet from my servlet:
import java.io.* ;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class ControlServlet extends HttpServlet {
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
//get the printwriter to output for debugging
PrintWriter out = response.getWriter();
//read in form variables
//String formUsername = request.getParameter("username");
//String formPassword = request.getParameter("password");
String action = request.getParameter("actionCode");
//convert String to int for action
//int actionInt = Integer.parseInt(action);
//add action variable to request
request.setAttribute("aktion", action);
//debug point 1
//use requestDispatcher to forward session info to JSP
RequestDispatcher dispatcher =
request.getRequestDispatcher("/mvcoutput.jsp");
dispatcher.forward(request, response);I have commented out a bit for debugging purposes, but basically, the form variables are read in, the username and password don't give me any problems, but the actionCode does. Upon forwarding to a basic jsp for testing my output displays value "null" when using the command:
request.getAttribute("aktion")Any reason why the hidden field is playing silly buggers ??
cheersAnyone ???
If I have a field in an html form which is hidden, do I retrieve it in the SAME WAY that I retrieve the non hidden form fields i.e. using the request.getParameter() method ??
Cheers. -
Safara 5.1.5 pass old value for a hidden field with new values
Hi
I have the JSP pages which used to be working in Safra 5.1.3. There is a hidden field: mac, submitted to and from this JSP page.
Page A submits "mac" with value1, backend a java action received this value and change it to value2 after some calculation, value2 is set to page B. I can see the hidden field "mac" contains value2 in page B. But when I submit page B, the value being transmitted is still value1.
I tested to change this field to a visible text field rather a hidden one. The value being passed will be the correct one: value2.
Other browsers except Safari 5.1.5 do not have such strange behavior.
Is there any solution for this problem apart from changing my form filed names?
Thanks.you can only list what was stored.
changes in values for a characteristic can be monitored in CL20N via menu Environment > Change documents
change history for classification is only stored if you activated this.
maybe it is not set active in your system, then see SAP Note 943559 - FAQ: Frequently asked questions about the classifctn. system -
Pass Hidden Field (Rep ID) as Parameter when user logs into site
I have set-up user validation to my site based on a userID and password, but I want to also pass a hidden field/parameter (RepID) to the rest of the site pages so that I can filter my record sets on those pages based on that RepID parameter.
I have coded everything the way I thought it should be, but I'm getting the following error when I test it and from what I can see it is defined...
Element PSWD is undefined in FORM.
Here is the form coding, as well as the CF coding for the user validation...
<form id="login" name="login" method="POST" action="<cfoutput>#MM_loginAction#</cfoutput>">
<table border="0" cellspacing="0" cellpadding="5">
<tr>
<td height="35" class="text_bold">Email</td>
<td height="35"><label for="email"></label>
<input type="text" name="email" id="email" /></td>
</tr>
<tr>
<td height="35" class="text_bold">Password</td>
<td height="35"><label for="pswd"></label>
<input name="pswd" type="password" id="pswd" value="<cfoutput>#rsWeblogin#</cfoutput>" /></td>
</tr>
<tr>
<td height="35" class="text_bold"><input name="salesman_id" type="hidden" id="salesman_id" value="<cfoutput>#rsWeblogin.SALESMAN_ID#</cfoutput>" /></td>
<td height="35"><input type="submit" name="submit" id="submit" value="Submit" /></td>
</tr>
</table>
</form>
<cfparam name="FORM.email" default="1">
<cfquery name="rsWeblogin" datasource="INSORB">
SELECT *
FROM dbo.WEBLOGIN
WHERE E_MAIL = <cfqueryparam value="#FORM.email#" cfsqltype="cf_sql_clob" maxlength="64">
</cfquery>
<cfif IsDefined("FORM.email")>
<cfset MM_redirectLoginSuccess="index.cfm">
<cfset MM_redirectLoginFailed="login.cfm">
<cfquery name="MM_rsUser" datasource="INSORB">
SELECT E_MAIL,PSWD FROM dbo.WEBLOGIN WHERE E_MAIL=<cfqueryparam value="#FORM.email#" cfsqltype="cf_sql_clob" maxlength="64"> AND PSWD=<cfqueryparam value="#FORM.pswd#" cfsqltype="cf_sql_clob" maxlength="15">
</cfquery>
<cfif MM_rsUser.RecordCount NEQ 0>
<cftry>
<cflock scope="Session" timeout="30" type="Exclusive">
<cfset Session.MM_Username=FORM.email>
<cfset Session.MM_UserAuthorization="">
</cflock>
<cfif IsDefined("URL.accessdenied") AND true>
<cfset MM_redirectLoginSuccess=URL.accessdenied>
</cfif>
<cflocation url="#MM_redirectLoginSuccess#" addtoken="no">
<cfcatch type="Lock">
<!--- code for handling timeout of cflock --->
</cfcatch>
</cftry>
</cfif>
<cflocation url="#MM_redirectLoginFailed#" addtoken="no">
<cfelse>
<cfset MM_LoginAction=CGI.SCRIPT_NAME>
<cfif CGI.QUERY_STRING NEQ "">
<cfset MM_LoginAction=MM_LoginAction & "?" & XMLFormat(CGI.QUERY_STRING)>
</cfif>
</cfif>
Any help would be greatly appreciated!I don't have anything definitive to offer other than a couple of questions based on what I see on your login form:
1. What is rsWeblogin that you are using to initialize the password field PSWD on the form? I would have expected the password field to be left empty in generating the form...
2. The use of "#rsWeblogin#" to initialize the PSWD field, coupled with the use of "#rsWeblogin.salesman_ID#" to initialize the hidden field strike me as odd; that second one would lead me to believe rsWeblogin is a structure of some sort, and I'm not sure what you would be getting crunched into the password field as a result...
Maybe one of those might give you some sort of clue?
In addition, if the password field is left empty on the form itself, you may well not be getting a FORM.pswd variable coming through the submittal. You may need to either check that it is defined (probably best) or cfparam it to a known value that would never be used for a "real" password (problematic for all sorts of reasons) before using it in the authentication logic.
/ron -
Passing values to hidden fields in screens
Hi ,
I have designed a screen which has i field which is output only, and two fields which are hidden.. the output only field gets populated when i select value from an alv tht pops up on the screen based on certain conditions.. the hidden fields should also be populated than.. but the hidden fields are not getting populated i think..
i have assigned a t-code to this screen,
and i need to call this transaction from another program passing values to all the fields.. i used parameter id for all teh fields, but values are not getting populated in the hidden and display fields. i gets in when i make it input enabled.. but i cannot let users enter values in 1 field, and i do not want users to see the other field.. What do i do???? please give your valuable suggestions. .a ny idea how to correct the issue?
Regards,
SuzieHi,
If you want one of the fields to be grey mode you can do that statically in the screen painter or dynamically in the progarm
in PBO
loop at screen
if screen-name = 'TO_BE_GREY_MODE'.
SCREEN-INPUT = 0
ENDIF
endloop
for hidden fields if the screen name and the variable name in the program are same the data transfer takes place but the users cannot see this.
Regards
Ramchander Rao.K -
Passing/retrieving hidden fields from Its template(IAC) to BSP page
Hi i m passing hidden fields from its template to custom BSP page...but not able to retrieve the hidden field in bsp page...is there any way we can retrieve the data....is there any equivalent of request.getattribute() method which we use in jsp to fetch the hidden fields....
<i>i m passing hidden fields from its template to custom BSP page...but not able to retrieve the hidden field in bsp page...</i>
from ITS template how are you calling/passing parameter to BSP
thru a form submit? or are you just openning the BSP thru a url link, in either case
you could pass the data as a form field (post) or in the url of the BSP (GET)
for example if the form field name in ITS template is myformfiled and you are submitting that to the BSP page then in the corresponding bsp page declare a page attribute withe same name (myformfiled) and mark the auto check box.
now the value passed from ITS template will be available within BSP in the ABAP variable myformfiled which you can use the way you want.
Hope this is clear
Raja -
Dear Friends,
Greetings to you all!
Below error is not allowing me to view the PLD on all inventory related documents like GRPO/DELIVERY/GOODS RECEIPT/GOODS ISSUE/Inventory transfer and also at invoice level if transaction was posted directly and attached file is for your information.
I couldn't find the (Field: F_060) and Variable '69' even in hidden files.
"Printing Error:Invalid variable number (RPT -6300) (Field: F_060) Variable '69' [Message 200-38]"
Request you to provide me the solution ASAP to clear this issue.
With warm regards
Rajesh Babu K
9959934444Dear Mr.Nagarajan garu,
Thanks for the reply and the problem is not with one specific PLD, even it is not allowing to view SAP given PLD's also.
And it is happening only with the inventory related transactions.
EX- If invoice had any base document then it can be viewable.
If Invoice/GRPO docs were directly posted then printing error is throwing
Thanks & Regards
Rajesh Babu K -
How to pass hidden field values on a click of a table row
hi all,
href = "bookAndNonBook.do"
I am very new to struts. I have created a table using displaytable tag which displays results in a tabular format. In addtion, i have a hidden field (prodType), the table rows are getting highlighted when i get my mouse on a particular row.
Following is the code from the results.jsp file
<body
onload="addRowHandlers('row', 'rowMouseOver')"
bgcolor="#FFFFFF" text="#000000" leftmargin="100" topmargin="50"
marginwidth="" marginheight="" rightmargin="30">
<html:form action="/bookAndNonBook" method="post">
<display:table name="sessionScope.productSearchList" id="row"
sort="list" export="true" defaultsort="1" defaultorder="ascending"
pagesize="15" decorator="org.displaytag.decorator.TotalTableDecorator"
class="dataTable">
<display:column property="prodType" title="ProdType" class="prodType"
headerClass="prodType" media="html" />
<display:column title="Title" property="titleName" sortable="true"
class="title" headerClass="title" />
</display:table>
</html:form>
</BODY>
I am calling a funtion addRowHandlers which passes the table id (which is row) and the rowMouseover for highlighting the rows on mouse over.
the code for function addRowHandlers is
function addRowHandlers(tableId, rowClassName) {
var previousClass = null;
var table = document.getElementById(tableId);
var rows = table.getElementsByTagName("tr");
for (i = 1; i < rows.length; i++) {
rows.onmouseover = function () {
previousClass = this.className;
this.className = this.className + " " + rowClassName ;
this.style.cursor="hand";
rows.onmouseout = function () {
this.className = previousClass;
this.style.cursor='';
rows.onclick = function (){
var cell = this.getElementsByTagName("td")[0];
var ProdType = cell.innerHTML;
alert("value of prodType = " + ProdType);
when i run the above code and click on a particular row it returns me the value in the hidden field i.e. prodType for that particular row
Now where i am having problem is i want that on the basis of prodType my jsp file should call different actions for different prodType as returned....somwhat a function like this
function submitProduct(prodType) {
if(prodType == "BK")
resultsForm.action = "/bookProduct.do";
else if(prodType == "NB")
resultsForm.action = "/nonbookProduct.do";
but i am unable to figure out that how do i this..
Any help will be really appreciated
Thanks
Samcan you please suggest some good struts forums where i can post my question
thanks in advance
Sam -
Hi all,
I wanna add a new field in ALV field catalog, so that when user choose function Change Layout to decide which fields are showed, they can choose the new field.
In orginal source, the ALV uses field catalog from structure<b> LIPOV.</b> And the field I wanna add is just a normal text field (char15, for example) and its data will be extracted from a select statement.
So, Here is the logic of report:
data: ls_fieldcat type slis_fieldcat_alv.
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
exporting
i_internal_tabname = 'itab_data1'
i_structure_name = 'LIPOV'
i_client_never_display = 'X'
changing
ct_fieldcat = ct_fieldcat[]
exceptions
inconsistent_interface = 1
program_error = 2
others = 3.
After this call, i add new field
ls_fieldcat-col_pos = 110. " above function will retrieve a field catalog with 109 records
ls_fieldcat-fieldname = 'new_text_field'.
ls_fieldcat-tabname = 'itab_data1'.
ls_fieldcat-seltext_l = 'NEW'.
ls_fieldcat-no_out = 'X'.
APPEND ls_fieldcat to ct_fieldcat .
clear ls_fieldcat.
Here, I copy all data from<b> itab_data</b> to <b>itab_data1</b>
Display:
call function 'REUSE_ALV_LIST_DISPLAY'
exporting
i_buffer_active = 'X'
i_callback_pf_status_set = gf_status
i_callback_user_command = gf_user_command
i_structure_name = 'LIPOV'
is_layout = gs_layout
it_fieldcat = ct_fieldcat
it_events = lt_events
it_sort = gt_sort
is_variant = gs_variant
tables
t_outtab = <b>itab_data1</b>
exceptions
program_error = 1
others = 2.
Please note that there are something special here:
Originally, ALV displayed with internal table itab_data.
The new filed is a part of internal table itab_data1.
<b>And the problem is:</b>
When I choose Change Layour (Ctrl F8) to select the new field to display, It does not appear in HIDDEN FIELD.
Any suggestion, plz.
Thank you very much.Clemens Li,
Thanks for your advice.
I have a new problem. Now, the new field appears in Selection. However, displaying the new field is impossible. My problem is:
- In default, 8 fields will display. Then, I use CHANGE LAYOUT to choose the new field which will be at 9th position. -> <b>I got a dump</b>... It informs that a Field Symbol is not assigned.
- Now, with the 8 fields above, I replace 8th position by the new field => It does not give me a dump but New field shows value of 8th field. I mean, if at first, 8th field is Quantity with value 10. Then I replace 8th field by my new field. When displaying again, it also gets 10 as its value.
- It is so strange. Because in function 'REUSE_ALV_LIST_DISPLAY', I used itab_data1, which consists of all field of itab_data and an addition field (NEW). I dont know why it does not show value of the new field while all old fields have right values. (before using that function, I copied all contents of itab_data to itab_data1)
So, everybody can help me this? Thanks -
For school I am working on an app using C# in visual studio that allows a student to enter their name, the number of points they earned and the points possible. When they click a submit button, the grade percentage is calculated in a hidden field and then
the percentage and letter grade should spit out into the gridview. THe issue I am having is trying to figure out how to translate within the if statements regarding the percentage amount equalling whatever letter grade, and then spit that letter grade out
into the gridview. Here is the code I have so far:
protected void btnSubmit_Click(object sender, EventArgs e)
SqlStudent.Insert();
hdnGradePercent.Value = (((int.Parse("txtPointsEarned.Text")) / (int.Parse("txt.PointsPoss.Text")) * 100)).ToString();
if ((int.Parse(hdnGradePercent.Value) >= 0) & ((int.Parse(hdnGradePercent.Value) <= 59)))
(this is where I am having trouble. I can't figure out how to get the letter grade and percent to spit out into the gridview.)
else if ((int.Parse(hdnGradePercent.Value) >= 60) & ((int.Parse(hdnGradePercent.Value) <= 69)))
else if ((int.Parse(hdnGradePercent.Value) >= 70) & ((int.Parse(hdnGradePercent.Value) <= 79)))
else if ((int.Parse(hdnGradePercent.Value) >= 80) & ((int.Parse(hdnGradePercent.Value) <= 89)))
else if ((int.Parse(hdnGradePercent.Value) >= 90) & ((int.Parse(hdnGradePercent.Value) <= 100)))
Any help would be greatly appreciated! I've been stuck on this for hours and I"m losing my mind!!Please post ASP.NET questions in the ASP.NET forums (http://forums.asp.net ).
Maybe you are looking for
-
How to get rid of '+' sign in front of ASM in OEM
I have the target name like '+ASM1_cad2updb001' in the OEM. For our program to work, I need to get rid of the plus sign at the begining. Can you tell me how to achieve this? Thanks! Edited by: user12238208 on Nov 30, 2009 1:31 PM
-
Hi! recently upgraded to 9i and migrated our spatial data too, for a week everything seem to be running fine but suddenly start getting this error: ORA-00604: error occurred at recursive SQL level 1 ORA-06521: PL/SQL: Error mapping function ORA-06512
-
I want to update CS Indesign CS6 to get the Folio Overlay plugin, but the updates could not be applied. The error log shows: DPS Desktop Tools CS6 2.05.1 Update Update is not applicable. Error Code: U44M2P28 Could anyone help me?
-
WRT350N- Firmware Upgrade Failed
when upgrading with .bin file (v1.05.8) via Administration - Firmware Upgrade, it fails when status showing 76% completion. Please help what i need to do? I already tried to boot in safe-mode to minimize programs running (firewall, etc), still showin
-
How do I switch from iPhone 5c to bluetooth earphone
I have paired my Motorola Bluetooth earphone to my new iPhone 5c. How do I switch from phone to bluetooth during a phone call ?