on 10-29-2009 5:17 AM
Hi
I am using JspDynpages & JSP using HTMLB for portal development.
in which i have a textbox control.
here when i type in textbox and click enter on keyboard i want to trigger the event of server side for ex:onSearchText of button and get the relavent data back.
I couldn't find any onKeyPress event for htmlb input filed.
Can any one suggest me how can I achieve it.
Thanks & Regards,
Chinna.
Hi,
Check this code.
<div class="field">
<hbj:label id="label_input_name" text="User Name" design="LABEL" required="TRUE" labelFor="user_id_input" />
<hbj:inputField id="userId" type="string" maxlength="100" value="" jsObjectNeeded ="true"/>
</div>
<SPAN STYLE="visibility: hidden">
<hbj:button id="Send_Button"
text="Submit" tooltip="Send feedback"
onClick1="onSendButtonClicked" width="100">
<% myFormId.setDefaultButton(Send_Button); %>
</hbj:button>
</SPAN>
This code will invoke server side on enter key press on input field. The submit button is hideen, if required you can set it visible by changing SPAN visibility.
<input type="text" id="search">
Use HTMLB coding for input fields
onClick1 please change to onClick
Regards
Baby
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
If my understanding is correct, then there is no need of any javascript.( Are u doing any kind of client side validation ?) If there is any validation required, then you can use button client side action event.
You only need to invoke server action on Enter key press in inputfield? isn't
The above code will create a button(default button), so inside the form if user press enter key it will execute the event assigned to the button(in our case onSendButtonClicked).
No need to write any explicit Javascript or onkeypress event.
If additional validation required for ur case let me know.
I will check and reply
Regards
Baby
Edited by: Baby on Oct 29, 2009 3:40 PM
Hi Baby,
You correctly understood my requirement, this is what exactly is my requirement. I don't want to do any client side validations. Just on click on enter key while the cursor is in text box, I want to trigger the button event (server side event).
I didn't try this code earlier, hence I was expecting that here will be java script code.
Now I tried your code, it is working as I expected.
Thanks a lot for the reply.
Awarded full points.
Thanks
Chinna.
Issue solved with the above code.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Baby,
This code is working for me when I have single Input field and a button in an iView. I need to implement the same where I have two Input fields and two buttons corresponding two each input field.
For ex: I have an Input field where I enter User Name and press enter key to search the user names, and in second Input field I enter city and press enter key to search cities.
Please advise me how to use the above code to cope to this requirement.
Thanks
Chinna
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Bala,
1. Are you using same method for both search.
2. Are you displaying both buttons in the interface with corresponding labels.
The only logic implemented in the code above is , for every form element we can set one button as default button. So if a user press enter key from any element in the form, the default button event will be triggered.
So simply you may need two Form, and in each form 1 button and 1 input field. Each button will act as default button for coressponding Form.
There may be also workaround like.. using javascript and triggering event explicitly.
If you can answer to above queries, then i will check let you know.
Please check the code, i could not test this code.
======================================
<hbj:form id="myFormId" ><div class="field">
<hbj:label id="label_input_name" text="User Name" design="LABEL" required="TRUE" labelFor="user_id_input" />
<hbj:inputField id="userId" type="string" maxlength="100" value="" jsObjectNeeded ="true"/>
</div>
<SPAN STYLE="visibility: hidden">
<hbj:button id="Send_Button"
text="Submit" tooltip="Send feedback"
onClick_="onSendButtonClicked" width="100"
design="EMPHASIZED">
<% myFormId.setDefaultButton(Send_Button); %>
</hbj:button>
</SPAN></hbj:form>
<hbj:form id="myFormId2" ><div class="field">
<hbj:label id="label_input_name" text="City Name" design="LABEL" required="TRUE" labelFor="city_id_input" />
<hbj:inputField id="cityId" type="string" maxlength="100" value="" jsObjectNeeded ="true"/>
</div>
<SPAN STYLE="visibility: hidden">
<hbj:button id="Send_Button2"
text="Submit" tooltip="Send feedback"
onClick_="onSendButtonClicked2" width="100"
design="EMPHASIZED">
<% myFormId2.setDefaultButton(Send_Button2); %>
</hbj:button>
</SPAN></hbj:form>
Regards
Baby
Hi,
Check this code.
This code will invoke server side on enter key press on input field. The submit button is hideen, if required you can set it visible by changing SPAN visibility.
<input type="text" id="search">
Use HTMLB coding for input fields
Regards
Baby
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
25 | |
12 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.