i'm developing a website, but i'm not an expert when it es to javascript. I'm using a script that i found on the internet for searching the page for a text string. To call this function i use the following code:
<div class="pesquisa" id="pesquisa"><form name="f1" action=""
onSubmit="if(this.t1.value!=null && this.t1.value!='')
findString(this.t1.value);return false">
<input name="t1" type="text" /></form>
</div>
this is working well, when i enter text and click enter he finds it on the page. Now i have a "button" next to it that is represented by:
<a href='javaScript:document.f1.findString(this.t1.value)'>
<div class="enviar" id="enviar">Pesquisar</div></a></div>
I want this "button" to call the same function with the value inserted in the form. But it is not working this way. Any ideas on how this can be made ?
Thanks in advance, Cláudio
i'm developing a website, but i'm not an expert when it es to javascript. I'm using a script that i found on the internet for searching the page for a text string. To call this function i use the following code:
<div class="pesquisa" id="pesquisa"><form name="f1" action=""
onSubmit="if(this.t1.value!=null && this.t1.value!='')
findString(this.t1.value);return false">
<input name="t1" type="text" /></form>
</div>
this is working well, when i enter text and click enter he finds it on the page. Now i have a "button" next to it that is represented by:
<a href='javaScript:document.f1.findString(this.t1.value)'>
<div class="enviar" id="enviar">Pesquisar</div></a></div>
I want this "button" to call the same function with the value inserted in the form. But it is not working this way. Any ideas on how this can be made ?
Thanks in advance, Cláudio
Share asked Jul 2, 2011 at 13:40 Cláudio RibeiroCláudio Ribeiro 1,6993 gold badges42 silver badges66 bronze badges2 Answers
Reset to default 1First, add an id
attribute to the textbox:
<input id="t1" name="t1" type="text" />
Then, in your <a>
tag, you can do this:
<a href="#" onclick="findString(document.getElementById('t1').value); return false;">Click Me</a>
Try this.. Add an id attribute to t1 (also called "t1"), and then reference it like this:
<a onclick="javaScript:findString(document.getElementById('t1').value)">
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745071588a4609581.html
评论列表(0条)