473,385 Members | 1,620 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Attaching Typeahead row with anchor tag

121 100+
I am using ajax call to populate data in my dropdown using Typeahead, now the HTML Typeahead creates for every row in dropdown look like

Expand|Select|Wrap|Line Numbers
  1. <li class="active" data-value="xx"> <a href="#"> my Text </a> </li>
My requiremnt is to have some value in anchor tag where when user clicks on dropdown text, it takes user to new page.

Can anyone point me in right direction? Any help will be appreciated.
Jun 19 '13 #1
2 1643
Claus Mygind
571 512MB
give your anchor an "id"

then use innerHTML to assign a text to the anchor

or .href to assign a link to the anchor

learn about all the anchor properties clicking here

try this sample code:
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <script type="text/javascript">
  5. function addtext()
  6. {
  7. document.getElementById('anchor1').innerHTML = "my text";
  8. document.getElementById('anchor1').href = "my_URL";
  9. }
  10. </script></head>
  11.  
  12. <body>
  13. <input type="button" value="go" onclick="addtext();" />&nbsp;<a id="anchor1" href="#"></a>
  14. </body>
  15. </html>
  16.  
  17.  
Jun 21 '13 #2
jay123
121 100+
This can be achieved by using updater attribute in Typeahead as code in updater gets called on click of row in Typeahead dropdown.

Expand|Select|Wrap|Line Numbers
  1. updater: function (item) {            
  2.        // do whatever you want to do here
  3.     }
  4.  
Jun 21 '13 #3

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

Similar topics

8
by: saif | last post by:
Hi all, I realy need your help. I have a page with different web links, now what I am trying to do is whenever a user clicks on a link that link is captured using event.target method. I'm...
6
by: Daniele Baroncelli | last post by:
Hi guys, I would like to change the text in an anchor. es. from <a id="idanchor">oldtext</a> to
3
by: v | last post by:
Hi guys, Is it possible to use a simple code to modify all the anchor elements on a web page to trigger a function eg to display the link innnertext on the window status upon mouseover? ...
5
by: elsenraat_76 | last post by:
Hello! I was wondering if someone could help me out with a problem I'm having? I'm trying to input a javascript value into an anchor tag (from a function), but don't have an event to call the...
6
by: Richard Brown | last post by:
Ok, I celebrate and rejoice in the Anchor property. So wonderful compared to the horrible 'resize' code I had to write in VB6, there is just no end to the wonders of VB.NET..... uh, ok..... BUT......
3
by: gary | last post by:
Hi, I am trying to reference an anchor in a user control with a url. This worked in 1.1 but no longer works in 2.0. The ascx control is located in a "/include" folder If you have a...
10
by: elibol | last post by:
Hi, Is there an event that fires when the back or forward button on a browser is pressed? I need an event to fire when someone clicks the back or forward button after an anchor has been set. ...
2
by: Sree | last post by:
Hello Friends, i was trying to read the Keyboard typeahead buffer from BIOS according to its address. But i'm not able to get the data. Please tell me how to do so. void main() { char far...
3
by: Joseph Gruber | last post by:
Hi all -- I have two questions. First, I'm adding a control to my form at runtime and the control/form seems to ignore the anchor property of the runtime control. Any idea how I can get a...
1
by: moltendorf | last post by:
I have a simple XMLHttpRequest that grabs a list of messages from my server (I posted a question for a different aspect of this earlier) I have decided to improve on it a little by adding in...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.