Why Javascript can't get value in Struts?

I have a button in Struts,when click this button,it will show a value in Struts,like follows:
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="form" %>
<script language="JavaScript">
function a(){
alert(username.value);
</script>
<form:form action="/register">
UserName:<form:text property="username"/><br>
enter password:<form:password property="password1"/><br>
re-enter password:<form:password property="password2"/><br>
<form:hidden property="abc" value="3"/><br>
<form:button property="button" value="Test" onclick="a()"/>     
<form:submit value="Register"/>
</form:form>
But when I click Test button,it can't show the value of parameter "username",why? How to show the value of it?
I have a another question,how many attribute of the taglib <form:>? Is there a document for it?
Thanks!

But when I click Test button,it can't show the value of parameter "username",why? How to show the value of it?
Paz>>
<script language="JavaScript">
function a(){
alert(document.forms[0].username.value);
</script>I have a another question,how many attribute of the taglib <form:>? Is there a document for it?
Paz>>
http://struts.apache.org//struts-doc-1.1/userGuide/struts-html.html

Similar Messages

  • Can you get values back from a stored procedure via OUTPUT parameters?

    Can you get values back from calling a stored procedure via OUTPUT parameters/variables? I call the SP via a SQL statement from a script either in a WF or DF.
    I thought I read some reference that DI could not get the values from OUTPUT parameters but I could not find it again (don't know if it is in any of the documentation or referred to in a forum.
    I did try a couple of tests but it did not reutrn any values via OUTPUT. But before I give up I thought I'd see if you could and maybe I needed to change something.

    This isn't exactly an answer to your question, but I'll point out that, given that you're resorting to a SQL script in the first place, there's no reason you can't also turn the output parameters into a regular result or record set. (The following uses T-SQL, although I think it's pretty generic.)
    declare @param1 int, param2 varchar(100), @return int;
    exec @return = proc @param1 = @param1 output, @param2 = @param2 output;
    select @param1 as param1, @param2 as param2;
    That is, to get from output parameters to a "regular" output from the SQL script isn't much of a leap...
    Jeff Prenevost
    BI Consultant
    Ann Arbor, MI

  • How can I get values from listbox?

    Hi all,
    I need to get price values from Price List (Inventory -> Item Master Data screen). It's important to get values from field 'Price' BEFORE item will be added/updated.
    How can I get values from Pricelist listbox?
    Thanks for any suggestions or short sample code.
    Best regards,
    Andy

    Hi Andy
    Here is som sample code that will get the description of the price list and also the price that is displaying at the time. The item master must be open for this snippet of code
      Public Sub GetItemPriceFromOpenWindow()
            'this is assuming item master is open
            Dim oEdit As SAPbouiCOM.EditText
            oEdit = SBO_Application.Forms.GetForm("150", 1).Items.Item("34").Specific
            SBO_Application.MessageBox(oEdit.Value)
            Dim oCmb As SAPbouiCOM.ComboBox
            oCmb = SBO_Application.Forms.GetForm("150", 1).Items.Item("24").Specific
            SBO_Application.MessageBox(oCmb.Selected.Description)
        End Sub
    Hope it helps

  • HT1454 why i can not get video out from my ipod touch after i did the upgrade

    why i can not get video out from my ipod touch after i did the upgrade

    why i can not get video out from my ipod touch after i did the upgrade

  • I'm staying at my house in Peru, South America. From my PC laptop I can see my neighbor's wifi service network, but I also have my mini iPad and I can not figure out why I can't get any wifi connection from my area. Is there a setting I need to do?

    I'm staying at my house in Peru, South America. From my PC laptop I can see my neighbor's wifi service network, but I also have my mini iPad and I can not figure out why I can't get any wifi connection from my area. Is there a setting I need to do?

    Yes, I did try to go on my settings>wifi and was waiting for any wifi signals to pick up, but nothing shows up. But on my PC I get a whole list of networks to choose from. Regarding my neighbor, I already have her password that is why I was able to get it on my PC, the problem is that the mini Ipad is not picking any signal neither can it locate me when I go to maps.

  • Faces config exception - Can't get value from value binding expression:

    the menuItem_Department shown property takes value from userRight's session bean object userDetail.
    class UserRights{
        public boolean mDept = false;
        public boolean loggedIn = false;
        public boolean admin = false;
       //accessors
    }now, the shown property picks correct value for #{userDetail.admin} but gives erros on this. any idea how to get around this exception:
    Managedbean menuItem_Department could not be created Can't get value from value binding expression: '#{userDetail.mDept}'.
    javax.faces.FacesException: Can't get value from value binding expression: '#{userDetail.mDept}'     at com.sun.faces.config.ManagedBeanFactory.evaluateValueBindingGet(ManagedBeanFactory.java:903)
         at com.sun.faces.config.ManagedBeanFactory.setPropertiesIntoBean(ManagedBeanFactory.java:547)
         at com.sun.faces.config.ManagedBeanFactory.newInstance(ManagedBeanFactory.java:233)
         at com.sun.faces.application.ApplicationAssociate.createAndMaybeStoreManagedBeans(ApplicationAssociate.java:256)
    .. stack tracepointers appreciated.
    reagrds
    Rabs

    well, i figured out the problem so thought to share with all aswell.
    all i changed was the name of the variable from mDept to dept.
    java beans has its own set of rules and naming conventions which i have not read much about but this problem had to do sumthing with that!
    just changing the name simply works fine!

  • How can i get value from tilelist?

    I have created checkbox in itemRenderer that use for TileList
    How can i get value (checked) from checkbox?

    "Marsza" <[email protected]> wrote in
    message
    news:g6r6vj$di0$[email protected]..
    > Help me please....... T_T
    Could you rephrase the question?

  • Does anyone know why I can only get sound and no video with a compatible component cable?

    Does anyone know why I can only get sound and no video with a compatible component cable?

    What apps are you trying?  TV out video only works with apps that support TV out.  If the app does not support TV out you will still get aoudio via the component cable

  • I want to talk to someone about why I can't get a data add on.

    I want to talk to someone about why I can't get a data add on. 150 useless none of the options get me to a real pErson. Tried to text that I wanted a data addin it keeps saying it is not available on this account. Been driven potty

    007 wrote:
    TextDP1 to 150 which is a£1100mb dataaddon for 7 days
    : DP1 is not an add-on; it is a Data Pack & it wont kick in till current pack expired.
    What  needs to do text 100 MB WEEK or 500 MB (for the month) to 150 to get data add-ons now as he wants.

  • Why i can't get the List's Index

    why I can't get the List's Index?Why I can't get the Command Action?
    below is the code.many thanks!
    import javax.microedition.lcdui.* ;
    import java.util.*;
    public class SelectCusScreen extends List implements CommandListener {
        public SelectCusScreen(Vector v) {
            super("people",Choice.EXCLUSIVE) ;
            Enumeration enumer = v.elements() ;
            while(enumer.hasMoreElements()) {
                //Adds an item consisting of one String to the Form
                append((String)enumer.nextElement(),null);
                //System.out.println(((String)enumer.nextElement()));
             addCommand(new Command("OK",Command.OK,1));
             setCommandListener(this);
        public void commandAction(Command c,Displayable s) {
            String cmd = getString(getSelectedIndex()) ;
            if(cmd.equals("OK")) {           
                 List l = (List) s ;
                int i = l.getSelectedIndex() ;
                System.out.println("something");
                String con = l.getString(i) ;
                System.out.println("your choise"+con);
    }[

    Not sure about espn.go.com, but on espn.com, Adblock Plus may prevent videos from playing. If you have that or another extension which blocks ads, try making an exception for the site.

  • Why javascript can't show right value under struts?

    I have a <html:select>,and when change the value of select,alert the current selected value,such pages include following value:
    PageID pageName
    1      Page 1
    2        Page 2
    3       �Page 3
    <html:select property="pageID" size="1" onchange="javascript:alert(this.options[this.selectedIndex].value)">
    <logic:iterate id="b" name="pages" type="com.PageID">
    <html:option value="<bean:write name='b' property='pageID'/>"><bean:write name="b" property="pageName"/></html:option>     
    </logic:iterate>
    </html:select>when i change the value of select,it don't show the right value,it should show 1,2 or 3,but it only show
    <bean:write name='b' property='pageID'/>
    why javascript don't show right value? How to show correct value of select?
    Thanks

    Working as intended !
    Its not your javascript its your JSP is wrong
    <html:option value="<bean:write name='b' property='pageID'/>">is bad JSp syntax you cannot nest tags like that.

  • How can i get value when the field name is user's defined

    Hi,
    I have a one java method:
    public ResultSet countUserDb(String id) {
    ResultSet rs = null;
    con = dbcon.connect();
    String queryString = ("select count as count from
    db_allocation where user_id='"+id+"'");
    Statement stmt = con.createStatement();
    rs = stmt.executeQuery(queryString);
    When i call it in a jsp file.
    ResultSet counter =db.countUserDb(request.getParameter("id"));
    if(counter.next())
    int x=rs.getInt("count");
    Tomcat said incorrect column name.How can i get the result set when the field name is user's defined.
    Best regards
    Ricky

    You should give the user defined name in the ResultSet.getXXX method to retrieve the column value.
    Example
    SQL:
    Select ename as employeename from emp;
    You should say :
    ResultSet.getString("employeename"); to get the value.
    Alternatively you can retrieve it using column number:
    ResultSet.getString(1);
    Chandar

  • Javascript can't get parent frame's dom

    the code like this:
    <pre><nowiki>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    </head>
    <input type="hidden" name="username" id="username" value="" />
    <frameset id="MainFrame" cols="0,0,*" border="0" frameSpacing="0" frameborder="no">
    <frame id="left" name="left" src="left.php" noresize scrolling="no" style="padding-left:20px;">
    <frame id="action" name="action" src="right.php" noresize scrolling="no">
    </frameset>
    </html>
    </nowiki></pre>
    does firefox will omit the code:
    <pre><nowiki><input type="hidden" name="username" id="username" value="" /></nowiki></pre>
    so when i in left.php or right.php can't get the input value?

    A good place to ask questions and advice about web development is at the MozillaZine Web Development/Standards Evangelism forum.
    The helpers at that forum are more knowledgeable about web development issues.
    You need to register at the MozillaZine forum site in order to post at that forum.
    See http://forums.mozillazine.org/viewforum.php?f=25

  • Why PhotoBooth can't get the background images to work properly on the picture

    Why PhotoBooth can get the background images to work properly on the picture, is it because too much luminosity in the environment or too little? I have tried everything and nothing works.
    <Re-Titled By Host>

    Might try this...
    Go to System Preferences > Universal Access and down in the Display: section make sure that the Enhance contrast: slider is all the way to left to Normal, or more to the right for less Contrast.
    Go to System Preferences > Accessibility in 10.8.x,and down in the Display: section make sure that the Enhance contrast: slider is all the way to left to Normal, or more to the right for less Contrast.

  • Why I can not get the medium crate of gold

    I need to ask why I buy medium crate of gold in the contract killer : zombies 2 I can not get it can help me check what happen

    What happens when you try to buy it ? If you are getting a message to contact iTunes support then you can do so via this page : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page, then try selecting Purchases, Billing & Redemption

Maybe you are looking for

  • Two Message Mappings in one Interface Mapping without using BPM

    Hello Experts, I have this scenario, please help me I have to execute two mappings of which one is a java mapping and then the other is a message mapping sequentially. The mapping is something like below Message1  -> (java Mapping) -> Message2 Messag

  • [Solved]Bash:Manipulating arrays of paths? the right way or not?

    Note: Refer to the following posts for better solutions and/or alternatives. This is a mock segment of a script I'm writting and I need to know if I'm doing it the correct way or at least in a proper bash way... the following works but will it always

  • I bought att-locked but contract-free iPhone 4 from the Apple Store in the mall

    Over 9 months ago i bought att-locked but contract-free iPhone 4 from the Apple Store in the mall. Now i live in Costa Rica so my question is can it be unlocked?

  • Where can I get sc5.1

    I need Sun C++ 5.1 compiler. Orbix 2000 needes this compiler. I am running Son OS 5.6. Does the 5.1 compiler come with the OS? Does it come with visual workshop? If it does then which version of the visual wprkshop does it comwe with? I would also ne

  • Resetting a JPanel

    I am writing to my JPanel (output) a variety of JLabels which contain images. This is the below snipped code.                   output.add(imageLabel[count]);This works fantastically, but the output JPanel is only reset when I close and reopen the ap