开发者

Using an image to submit a search form

I have done this a lot of times but I have a problem, I'm trying to do it with the google form, the google name have slashes so is not working on all browsers, is there a different way to do this?

Any clue is good :D

code:

        <form action="http://www.webpage.com/search.php" id="cse-search-box" name="cse-search-box">
          <div>
            <input type="hidden" name="cx" value="partner-pub-number" />
            <input type="hidden" name="cof" value="FORID:number" />
            <input type="hidden" name="ie" value开发者_运维技巧="ISO-8859-1" />
            <input type="text" name="q" size="31" class="form-search" />
        <a name="sa" id="sa" href="javascript:document.cse-search-box.submit();"><img src="images/arrow.jpg" class="img-search"/></a>
          </div>
        </form>


<input type="image" src="path/image.png" />


<input type="image" ...> is what is used for images acting as submit buttons.


- is the minus operator, so document.cse-search-box doesn't mean what you think it does -- further, this way of accessing elements is obsolete. Use getElementById instead:

document.getElementById('cse-search-box').submit();

Actually, you don't even need JavaScript to do this. There are at least 2 ways to do it using HTML alone:

<input type="image" src="images/arrow.jpg" />

or:

<button type="submit"><img src="images/arrow.jpg" /></button>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜