你如何同时使用$ _GET和#锚链接? [英] How do you use $_GET and # anchor link at the same time?

查看:105
本文介绍了你如何同时使用$ _GET和#锚链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表单,可以用$ _GET重定向到原始表单页面,以显示任何错误。但是表单本身在页面的下方。



我试过 www.abc.com/index.php?error=missing_input&#review

code>

解决方案

是的,这绝对是为我工作

 <?php 

if(!isset($ _ GET ['submitted'])){
echo< form action ='#fragment'>< input type ='text'name ='text'> < input type ='submit'name ='submitted'value ='Do it'>< / form>;
} else {
echo< div style ='height:800px'>纵向填充< br>您的文字是:{$ _GET ['text']}< / div>< div id ='fragment'>这是片段< / div>;



$ b如果它不适合你,元素在您生成的页面上带有参考ID,或者您通常对URL片段定位符的工作原理错误。



玩这个简单的代码,并且如果您还有其他问题,请回复我。


I have a form that redirects to the original form page with $_GET to display any errors. But the form itself is place lower down the page. What is the correct way to use both?

I tried www.abc.com/index.php?error=missing_input&#review

解决方案

Yep, it's definitely working for me:

<?php

if (!isset($_GET['submitted'])) {
    echo "<form action='#fragment'><input type='text' name='text'><input type='submit' name='submitted' value='Do it'></form>";
} else {
    echo "<div style='height: 800px'>Vertical Padding<br>Your text was: {$_GET['text']}</div><div id='fragment'>This is the fragment</div>";
}

If it's not working for you, I suspect that either don't have an element with the reference ID on the page you are producing, or you generally have the wrong idea about how URL fragment anchors work.

Have a play with that simple code, and come back to me if you have any more problems.

这篇关于你如何同时使用$ _GET和#锚链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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