423,504 Members | 1,125 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,504 IT Pros & Developers. It's quick & easy.

Go to Webpage on Combo Box Select

P: 58
Hi All,

i am new to java script

i need one requirement that is

i want to display a combo box and

when i select one option in it i should go to one jsf page

how can i get this using script.

can any body help me...
Jan 25 '07 #1
Share this Question
Share on Google+
8 Replies


acoder
Expert Mod 15k+
P: 16,027
See this example. When you select an item in the combo box, it goes to the webpage. Adapt to your needs.
Jan 25 '07 #2

P: 58
Thank you,

but how can i display a text box like search engine

means suppose if i enter some customer name i need him details

how can i get it
Jan 25 '07 #3

acoder
Expert Mod 15k+
P: 16,027
Thank you,

but how can i display a text box like search engine

means suppose if i enter some customer name i need him details

how can i get it
An example of a text box:
[HTML]<input type="text" id="textid" name="textname" value="some val">[/HTML]
For the customer details, you'll have to give more details. You'll need server side code to get the customer details off a database.
Jan 25 '07 #4

P: 58
An example of a text box:
[HTML]<input type="text" id="textid" name="textname" value="some val">[/HTML]
For the customer details, you'll have to give more details. You'll need server side code to get the customer details off a database.
ok thank you

how can i go from one jsf page to another jsf page.........see my code

Expand|Select|Wrap|Line Numbers
  1. <%@page contentType="text/html"%>
  2. <%@page pageEncoding="UTF-8"%>
  3. <%@taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
  4. <%@taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
  5. <html>
  6.     <head>
  7.         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  8.         <title> Detail of customer</title>
  9.         <script type="text/javascript">
  10.  
  11.             function myfunction()
  12. {
  13. <a href="examplescript.jsp">broadband</a>
  14. }
  15.  
  16.  </script>       
  17.     </head>
  18.     <body>
  19.  
  20.      <f:view>
  21.             <h1>Enter Customer Id</h1>
  22.  
  23.        <h:form id="jsftag" >
  24.              <h:inputText id="customer" /><br>
  25.                   <br>
  26.              <h:commandButton    id="getservices"   value="get Services"
  27.                            onclick="myfunction()" >
  28.  
  29.              </h:commandButton> 
  30.  
  31.  
  32.  
  33.   </h:form>
  34.   </f:view>
  35. </body>
  36. </html>
  37.  
  38.  
i have written like this..

shall i mension that <a href ..>tag in a function?...

while running i got error as error in java scipt page...

if not how can i achieve it?
Jan 29 '07 #5

acoder
Expert Mod 15k+
P: 16,027
Use
Expand|Select|Wrap|Line Numbers
  1. location.href="examplescript.jsp";
instead.
Jan 29 '07 #6

P: 58
Use
Expand|Select|Wrap|Line Numbers
  1. location.href="examplescript.jsp";
instead.

Hi,
the code which you mensioned is not working...

I displayed a command button not combo box.....

please see the code once and tell me the solution..
Jan 30 '07 #7

acoder
Expert Mod 15k+
P: 16,027
So do you want a command button or a combo box?

If you want a combo box, check the link I gave you earlier. If you want a command button, I've modified your code below:
[HTML]<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title> Detail of customer</title>
<script type="text/javascript">
function myfunction() {
location.href="examplescript.jsp";
}
</script>
</head>
<body>
<f:view>
<h1>Enter Customer Id</h1>
<h:form id="jsftag" >
<h:inputText id="customer" /><br>
<br>
<h:commandButton id="getservices" value="get Services"
onclick="myfunction()" >
</h:commandButton>
</h:form>
</f:view>
</body>
</html>[/HTML]
Jan 30 '07 #8

acoder
Expert Mod 15k+
P: 16,027
Also see how to use JavaScript with JSF in this article.
May 18 '08 #9

Post your reply

Sign in to post your reply or Sign up for a free account.