Computer problems,Computer help
*AX SOFT>>>Programming & Design

I need a script that can verify if a link is on a certain page. Please read all details before answering, Thx!


Here is the deal:

1) Visitor comes to my link site and chooses a category where he/she thought they submitted a link to, but doesn't bother checking if it is on that page.
2) The person decides they want to update their link with new information and click on the UPDATE YOUR LINK button on the top of the page.
3) They enter in the URL of the link they want to edit.
4) *Here is where I need the cgi or perl, or javascript code) The form they entered the url into checks ONLY the page they are currently on to see if the link is there. If YES, it allows them to edit the link, showing them a form that is pre-filled with the data from the url they entered. (url name, description...) and they can submit the changes to me.
If NO, it tells them that their link is NOT on this page, and please go to the correct page to update the ad.

If you know of a script like this, PLEASE let me know asap, email me if you have to, but I need this asap. Thank you in advance!

getElementsByTagName('a') will return an array of all anchor elements in the page. Compare the href attributes of those items to the requested url until you find a match or fail.

<html>
<head>
<!--
No matter which you select
as "best answer" - pick one.
-->
<script>
function get(eid) {
var d = document;
var r = d.getElementById(eid);
return r;
}

function update() {
var isInPage = false;
var link = get('link').value;
var d = document;
var links =
d.getElementsByTagName('a');
var last = links.length;
for (var i = 0; i < last; i++) {
isInPage = link == links[i].href;
if (isInPage) break;
}
if (isInPage) {
// do submit
alert('link is in page');
}
else {
// do error process
alert('link is NOT in page');
}
}
</script>
</head>
<body>
<p>
<a href="http://www.d.org/link1.html">
text for link 1</a>
</p>
<p>
<a href="http://www.d.org/link2.html">
text for link 2</a>
</p>
<p>
<a href="http://www.d.org/link3.html">
text for link 3</a>
</p>
<p>
<a href="http://www.d.org/link4.html">
text for link 4</a>
</p>
<form>
Enter link to update:
<input type="text" id="link" />
<input type="button"
value="submit change"
onclick="update();" />
</form>
</body>
</html>

I don't have a script for you, but I have an idea on how to do it. Basically, the <a href> needs to be named. Then, the <a href = <% userlink %>. The value needs to be linked to userlink, but the default of the userlink is what ever you set it to. If I had more time, I'd attempt the script for you, but I gotta goto work soon.

I'm not sure if it will help you but try this.
On the page that suppose to be the link, you can enclose the link with a html tag, maybe div, and then look if this tag has a link or not just with the string's length.

You're allowing users to edit the page directly - bad idea.

The links should be in a database, with the page being created dynamically, so that the "link" can be checked for validity.

If the user wants to edit the link, he merely edits the database entry. Finding whether the link exists (in the database) then becomes trivial - the count of that link in the database is 1. If it's 0, the link doesn't exist in the database. (Check for SQL injection, of course.)

Tags
  General - Computers & Internet   Software   Security   Programming & Design   Facebook   Flickr   Google   MSN   MySpace
Related information
  • How can market knowledge be improved for GlaxoSmithKline using the internt or the WWW??

    You're lucky girl coz i answer you : Use this .. ...

  • How to Write a SQL statement to display the repeated rows of the table below:?

    Ok, I will assume that 'topic_id' is the criteria for determining if the row is repeated (i.e. topic_id is the same on two or more items). I am giving you a generic way of dealing wit...

  • Html software doubt?

    www.w3.org has an HTML validator and a CSS validator that are great for helping you to debug your code: HTML Validator (first step) ...

  • Output of a C++ program?

    we come to if (a++ <= --b && c != b) first b is pre-decremented now a=6 b=5 c=20 now the "if" expression is evaluated, which, translates to (6 <= 5 && 20 !=...

  • I am using oracle 9i. i have a column in a table,that column is a foreign key. can that froign key as a uniqu?

    Your English is very garbled, but I will try to answer as best I can. A foreign key does not have to be unique IN THE TABLE IN WHICH IT IS THE FOREIGN KEY. In fact, it is very commonly the case ...

  • Assembler language: what is the condition code when comparing the characters 1 and ' '.?

    Comparing the '1', '0' and the space are comparing hex values: 0x31, 0x30, and 0x20 CLC '1', ' '; // compare 0x31, 0x20 CLC '0', ' ' ...

  • Which company I should consult to get a good rate for buidling my website.?

    First of all never put your budget in open, everybody will bid more than that . You can post your project at freelance websites like ...

  • I placed png files in word then i created a pdf and they look crappy i dont understand?

    Some applications do not handle png formatted images. Try using the standard jpeg format and save as best quality possible. Ron

    ...
  •  

    Categories--Copyright/IP Policy--Contact Webmaster