基于文本输入字段创建动态链接 [英] create dynamic link based on text input field

查看:124
本文介绍了基于文本输入字段创建动态链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图创建一个文本输入字段,游客可以输入一个值,然后点击或提交。

I'm trying to make a text input field where visitors can enter a value and then hit go or submit.

根据它们将发送的数字号码到一个新的页面。

Based on the digit number they would be send to a new page.

例如,如果他们输入123并点击提交,它会将它们发送到 http://www.example.com/page/123

For example if they enter 123 and hit submit it would send them to http://www.example.com/page/123

有人能帮我解决这个问题吗?运行?
谢谢

Could anybody please help me get this up and running? Thank you

推荐答案

这里我们去玩得开心。只需复制代码并将其保存为html即可。你不需要PHP或这样的。

Here we go have fun. just copy the code and save it as html. you don't need php or such. it is way too simple to need a server side code.

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Untitled Page</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.0.min.js"></script>

<script type="text/javascript">

$(document).ready(function(){

    $('#button').click(function(e) {  
        var inputvalue = $("#input").val();
        window.location.replace(" http://www.example.com/page/"+inputvalue);

    });
});
</script> 
</head>
<body>

       <input type="text" value="11" id="input"> 
       <button type="button" id="button">Click Me!</button>
</body>
</html>

这篇关于基于文本输入字段创建动态链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆