473,976 Members | 30,806 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to locate a on a web page according to parameter submitted with a form

5 New Member
I have a wab page with pattern :
[HTML]<a name="a">a</a>
<a name="b">b</a>
<a name="c">c</a>
<a name="d">d</a>
<a name="e">e</a>
[/HTML]
i put anchor links to be able to locate on every item.
And at the top of the page i have a form including only a textbox and a submit button. now what i want to do is either with javascript or something else, locate on the item which has the anchor name value equal to the string which is entered by the user to the forms textarea. anybody can help me ??
thanks everybody a lot
Aug 20 '07 #1
7 1377
acoder
16,027 Recognized Expert Moderator MVP
Welcome to TSDN!

You can access the anchor by adding a # before the name:
Expand|Select|Wrap|Line Numbers
  1. var dest = document.getElementById('txtAreaID').value;
  2. location.href='#'+dest;
Aug 20 '07 #2
salla83
5 New Member
i add the code you give and it work but with a little problem. when i type p and click submit the page locates to the anchor with the name property p but relocates to the top of the page again suddenly. i couldn't fix the problem here is the code of my page. please help. thank you.

[HTML]<script language="javas cript">
function locate()
{
var dest = document.getEle mentById('text1 ').value;;
location.href=' #'+dest;
}
</script>

</head>

<body>

<form name="form1">
<input type="text" name="textfield " id="text1"/>
<input type="submit" name="Submit" value="GO" onclick="locate ()"/>
</label>
</form>
<br/>
<br/>
<br/>
<br/>
<br/><br/>
<br/>
<br/><br/>
<br/>
<br/>
<a name="a">a</a><br /><br />
<a name="b">b</a><br /><br />
<a name="c">a</a><br /><br />
<a name="d">a</a><br /><br />
<a name="e">a</a><br /><br />
<a name="f">a</a><br /><br />
<a name="g">a</a><br /><br />
<a name="h">a</a><br /><br />
<a name="i">a</a><br /><br />
<a name="j">a</a><br /><br />
<a name="k">a</a><br /><br />
<a name="l">a</a><br /><br />
<a name="m">a</a><br /><br />
<a name="n">a</a><br /><br />
<a name="o">a</a><br /><br />
<a name="p" id="p">p</a><br /><br />
</body>
</html>[/HTML]
Aug 20 '07 #3
acoder
16,027 Recognized Expert Moderator MVP
Please use CODE tags when posting code. Thanks!

This might have something to do with the fact that you're setting the id of "p" too.
Aug 20 '07 #4
salla83
5 New Member
i remove the id tag but it still has the same problem. does it works in your browser? if so that means my browser (ie6) has problems with the script and i gotta do something, if not please help me.
Aug 20 '07 #5
Logician
210 New Member
i add the code you give and it work but with a little problem. when i type p and click submit the page locates to the anchor with the name property p but relocates to the top of the page again suddenly. i couldn't fix the problem here is the code of my page. please help. thank you.
You are submitting the form, which causes the page to reload. Use
Expand|Select|Wrap|Line Numbers
  1. <input type=button ....
or return false in the onclick handler.
Aug 21 '07 #6
salla83
5 New Member
thank you all for your help. it's working now.
Aug 21 '07 #7
acoder
16,027 Recognized Expert Moderator MVP
Glad you got it working. Post again if you hit a problem.
Aug 21 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

15
4354
by: wk6pack | last post by:
Hi, I have a problem and not quite how to go about solving it. I have a form written in asp. I wish to submit the form and have the server return back to the same page without actually refreshing the page. I know I could write a form, submit it and go to another page. I've searched the web and I see something about HTTP Status code of 204
2
2269
by: J Krugman | last post by:
I have a form with a couple of submit buttons, plus a "pseudolink" that is also supposed to submit the form; the submitted form data feeds to a CGI script. The two submit buttons have the name "go_for_it", so that when the form is submitted, the CGI script looks for the value of the CGI parameter "go_for_it". I want the pseudolink to set the value of this CGI parameter prior to submitting the form, but I can't get it to work. Here's the...
2
3838
by: anonieko | last post by:
Scenario: You have a page that is TOO slow to refresh. But it allows partial flushing of html contents. I.e. Submit button already appears but you don't want your users to click on it prematurely because other parts are still coming. Here I put a javascript the will enable only submit button only after 5 seconds after the page is load fully.
2
19557
by: Ben Turner | last post by:
Hi, I need to create an ASPX page that includes both traditional HTML Forms (which are submitted to a third-party site like a travel booking service) and also make use of the ASP.Net form. I've tried a number of approaches so far but none seem to really suffice: 1. Position the HTML form elements absolutely and simply write the HTML after the </form> tag. This sort of works but then allows no server control over the creation of the...
7
2059
by: Tom wilson | last post by:
I have created a very simple example that doesn't work. Form1 contains a textbox and a button: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Response.Redirect("login.aspx") End Sub Very simple. Forget what login.aspx does, it's just somewhere to redirect to.
6
4922
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of the html page controls the form fields that are required. It doesn't function like it's supposed to and I can leave all the fields blank and it still submits the form. Also I can't get it to transfer the file in the upload section. The file name...
16
3169
by: whyyyy | last post by:
The script below works fine if the form is filled out and submitted. But a (blank) e-mail is sent whenever the page loads, even when the form is not submitted. I would like to receive the e-mail only when the form is submitted <%@LANGUAGE="VBSCRIPT"%> <% Set MyMail=CreateObject("CDO.Message")
4
7488
by: evgenyg | last post by:
Hello ! We have the following situation - when Ajax request is sent what's being returned by the server is usually an XML (which is used for DOM updates) but sometimes it's HTML which is a whole new page that should replace an existing one. I.e when we issue an Ajax request we don't know what will be returned and analyze the response to act accordingly. Now, the way to replace the current document with a new one used to be easy and...
5
14142
by: c676228 | last post by:
Hi everyone, my colleagues are thinking about have three insurance plans on one asp page: I simplify the plan as follow: text box:number of people plan1 plan2 plan3
0
10170
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11815
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
11570
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10081
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8456
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7602
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6414
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6554
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
5150
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.