且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

jQuery转到表单提交中的URL,并将字段值添加到URL字符串中

更新时间:2023-12-03 07:52:58

谢谢你们在此方面的帮助...

thank you both for your help on this...

我不确定我的方法是否在做错事,或者我没有描述我需要做的足够好...

I'm not sure if I was doing something wrong with your methods or if I hadn't described what I needed to do well enough...

最终我的解决方案是...

The solution in the end for me was this...

第一个文件包含一个带有method="get"

first file contains a a form with method="get"

< form method="get" action="getParams.html">
First Name: < input type="text" name="firstName" id="firstName" />
Surname: < input type="text" name="surname" id="surname" />
< input type="submit" id="submit" value="submit"/>
< /form>

这指示获取参数,并且随着method = get url以getParams.html?firstname=""&surname=""

this directs to get params and as the method=get the url ends with getParams.html?firstname=""&surname=""

然后在getParams.html页面中,此代码仅用于从url格式化(如我所需要的那样)并重定向...

Then in the getParams.html page this is simply used for the formatting (as i need it to be) from the url and redirect...

我在此插件http : // projects.allmarkedup.com/jquery_url_parser/

与js:

var firstName = jQuery.url.param("firstName");
var surname = jQuery.url.param("surname");
location.href = 'http://myOnlineMag/issue01.html?params=' + firstName + '*' + surname; 

将我想要的值作为vars拉出url,然后将它们附加到我的url的末尾. (我需要使用这种特定格式的文件-在项目上线之前不能共享链接,但是如果您愿意,我可以在下周发布.)

pulls the values I want form the url as vars then attaches them to the end of my url. (I needed these in this specific format - can't share a link until the projects live but I can post next week if you would like.)