[Rails] javascript help
Steve Odom
steve.odom at gmail.com
Sat Apr 1 00:42:37 GMT 2006
Thanks to both of you for the help. Your comments helped steer me in the
right direction.
I'm using the behaviour.js library so has allowed me to simplify it
somewhat. Here is my js:
'.tag_link' : function(el){
el.onclick = function(){
var str = document.tag_form.discover.value + ", " + el.rel
document.tag_form.discover.value = str;
}
},
And my form:
<form name="tag_form">
<input type="text" name="all" id="discover" size="16" value="test1, test2"/>
<a href="#" rel="mytag1" class="tag_link">click me</a><br />
<a href="#" rel="mytag2" class="tag_link">click me</a><br />
<a href="#" rel="mytag3" class="tag_link">click me</a><br />
</form>
It validates (except for not having an action in the form tag, which I'll
add in a bit. Does anyone see any problems with this? Seems to work fine.
Steve
http://www.smarkets.net
On 3/31/06, njmacinnes at gmail.com <njmacinnes at gmail.com> wrote:
>
> Well, first of all, the button should be between the <form> ...
> </form> tags (it should work even if not, but lets just be strictly
> correct).
> Your form needs a name, for example <form name="form1">. Then its'
> onClick="document.form1.discover.value = test3, test4" Notice only one
> equals, not two? That should sort it out. Hope that's helped.
> -N
>
> On 31/03/06, Steve Odom <steve.odom at gmail.com> wrote:
> > Hi list,
> >
> > I have a list of tags. I want to be able to click on a tag and have that
> tag
> > name populate an input field. I think delicious used to allow you to
> click
> > on existing links to tag your bookmark similar to this (moving instead
> to
> > auto_complete).
> >
> > My guess is the code looks something like this....
> > <form>
> > <input type="text" name="all" id="discover" size="16" value="test1,
> test2"/>
> > </form>
> >
> > <a href onClick="document.form.discover.value == 'test3, test4'">click
> > me</a>
> >
> > ...but I can't get it to work. Any suggestions?
> >
> > Thanks,
> >
> > Steve
> > http://www.smarkets.net
> >
> > _______________________________________________
> > Rails mailing list
> > Rails at lists.rubyonrails.org
> > http://lists.rubyonrails.org/mailman/listinfo/rails
> >
> >
> >
> _______________________________________________
> Rails mailing list
> Rails at lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060401/964175c9/attachment.html
More information about the Rails
mailing list