Jump to content

set a specific time for submitting a form to webserver


hisoka

Recommended Posts

OK suppose I have a webpage with a submit form and using JavaScript , I must do the following :



1) multiple 40 with 2

2) put the result in the submit form box

3)click submit to send the result to the server . The result that is 80 should be returned in one second

 

manually , I cannot send the form in one second . So I would like to know How to do it in one second using JavaScript ? and/or what is the tool to do it ?

Link to comment
Share on other sites

Sending to server, which would normally take longer than second, because the page reloads completely, unless you use AJAX, to process the result in a separate php file, return result to current form and use setimeout() to show result after 1000 milliseconds, would be more closer to a second delay than a relying on complete reload using submit.

Edited by dsonesuk
Link to comment
Share on other sites

If you want to have a delay before something happens then you can use setTimeout to schedule a function to run later.

 

that is a very good idea . However I do not want to have a delay before a function runs . I would like to submit a form in a specific time without putting a delay . Is it possible ? if yes how ? if not why ?

Link to comment
Share on other sites

You either want a delay or you don't.

 

If you're asking for the result to appear in one second then you want a delay of one second.

 

I misunderstood the word delay and thanks to what you wrote Foxy Mod I understood what it means . It is like a bomb . You set a time for it after which it will automatically explode . You can set a time of 30 seconds or 10 seconds or 5 seconds .

Link to comment
Share on other sites

I am now reading carefully but I need to ask some questions in between .

 

This is a source code :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--[if IE 6]>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" class="lteIE6">
<![endif]-->
<!--[if IE 7]>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" id="ie7">
<![endif]-->
<!--[if !(IE 6) & !(IE 7)]><!-->
<html lang="en">
<!--<![endif]-->
<head profile="http://gmpg.org/xfn/11">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Local file inclusion | DDXhunter, Hack 'n Web</title>
<link rel="pingback" href="https://ddxhunter.wordpress.com/xmlrpc.php" />
<link rel="alternate" type="application/rss+xml" title="DDXhunter, Hack 'n Web » Feed" href="https://ddxhunter.wordpress.com/feed/" />
<link rel="alternate" type="application/rss+xml" title="DDXhunter, Hack 'n Web » Comments Feed" href="https://ddxhunter.wordpress.com/comments/feed/" />
<link rel="alternate" type="application/rss+xml" title="DDXhunter, Hack 'n Web » Local file inclusion Category Feed" href="https://ddxhunter.wordpress.com/category/web-hacking/local-file-inclusion/feed/" />
    <script type="text/javascript">
        /* <![CDATA[ */
        function addLoadEvent(func) {
            var oldonload = window.onload;
            if (typeof window.onload != 'function') {
                window.onload = func;
            } else {
                window.onload = function () {
                    oldonload();
                    func();
                }
            }
        }
        /* ]]> */
    </script>
    <link rel='stylesheet' id='all-css-0' href='https://s0.wp.com/_static/??-eJx9j90KwjAMhV/IGvzFXYjPsnaxq0uWsqaMvb2dIoKT3YTkcD5ODozROOkVewXOJlL2oU8wRidsEgfC6efaupQ28B+j0GGCB2qsXWde18JuSfwXEO+xkazmLkQywhgaj7qW4WTAonOsdXYwNqFGQi62NYzj+UPNa1seXK3y7mxtHDAlUyaHzEbbErTk3jLEbIGlyVQPQafSXxGSToQzcOPr7niq9sdddbg8nkinjQs=''>https://s0.wp.com/_static/??-eJx9j90KwjAMhV/IGvzFXYjPsnaxq0uWsqaMvb2dIoKT3YTkcD5ODozROOkVewXOJlL2oU8wRidsEgfC6efaupQ28B+j0GGCB2qsXWde18JuSfwXEO+xkazmLkQywhgaj7qW4WTAonOsdXYwNqFGQi62NYzj+UPNa1seXK3y7mxtHDAlUyaHzEbbErTk3jLEbIGlyVQPQafSXxGSToQzcOPr7niq9sdddbg8nkinjQs=' type='text/css' media='all' />
<link rel='stylesheet' id='screenprojection-css-1' href='https://s1.wp.com/wp-content/themes/pub/modularity-lite/library/styles/screen.css?m=1289600476h' type='text/css' media='screen, projection' />
<link rel='stylesheet' id='print-css-2' href='https://s1.wp.com/wp-content/themes/pub/modularity-lite/library/styles/print.css?m=1361549426h' type='text/css' media='print' />
<!--[if lte IE 8]>
<link rel='stylesheet' id='modularity-ie-css' href='https://s0.wp.com/wp-content/themes/pub/modularity-lite/library/styles/ie.css?m=1276553573h&ver=4.5.1' type='text/css' media='all' />
<![endif]-->
<!--[if lte IE 7]>
<link rel='stylesheet' id='modularity-ie-nav-css' href='https://s0.wp.com/wp-content/themes/pub/modularity-lite/library/styles/ie-nav.css?m=1276553573h&ver=4.5.1' type='text/css' media='all' />
<![endif]-->
<link rel='stylesheet' id='all-css-7' href='https://s1.wp.com/_static/??-eJx9i1EKwkAMRC/kGgor6od4lu0S05RsUpotXt+VQqko/gwzzHvwnEI2ragVyhImWYjVAYuNvOYxux+AQa1yI30r6/HbJ7QgllNl048RHpJ4/qfO2ItRqwSN2s0vqQ5Y0GGIQGJ9kjdwL7cunq4xXs5dHF9ualHF' type='text/css' media='all' />
<script type='text/javascript'>
/* <![CDATA[ */
var LoggedOutFollow = {"invalid_email":"Your subscription did not succeed, please try again with a valid email address."};
/* ]]> */

1)why is some HTML between <--> ?

document.getElementById(id)

is used to find element by element id . So I applied it on the source code above like this :

document.getElementById('ie7')

but it gives null as a result ? why ?

 

then

document.getElementById('all-css-0')

gives me this :

<link media="all" type="text/css" href="https://s0.wp.com/_static/??-eJx9j90KwjAMhV/IGvzFXYjPsnaxq0uWsqaMvb2dIoKT3YTkcD5ODozROOkVewXOJlL2oU8wRidsEgfC6efaupQ28B+j0GGCB2qsXWde18JuSfwXEO+xkazmLkQywhgaj7qW4WTAonOsdXYwNqFGQi62NYzj+UPNa1seXK3y7mxtHDAlUyaHzEbbErTk3jLEbIGlyVQPQafSXxGSToQzcOPr7niq9sdddbg8nkinjQs=" id="all-css-0" rel="stylesheet">

why it gives me that whole stuff . It should give me only as I asked only for the element

 id="all-css-0"

???

 

One last question

document.getElementById(id)

is used to find an element by element id . What if I cannot access the source code or I want to find an element by its id without accessing the source code . So for example how can I use

document.getElementById()

to access the

 'all-css-0'

element without seeing the source code ???

Edited by hisoka
Link to comment
Share on other sites

Sometimes people comment out pieces of code they think are no longer needed but might want to use in the future. Things between <!-- --> are not shown on the page. In this particular case, some of that code is only meant to be shown in Internet Explorer.

 

document.getElementById('ie7') returns null because at the moment of execution the element did not exist on the page.

 

document.getElementById('all-css-0') returns an element. The element is everything you saw in the console. That's what an element is. If you don't want an element then don't ask for one. getElementById() finds an element that has an id attribute with the value you specified.

 

If all you want is the string "id='all-css-0'" then just type that:

var whatIWant = "id='all-css-0'";

I cannot understand your last question. What you're asking does not make any sense.

Link to comment
Share on other sites

Source code means everything that makes up the webpage? IF you mean by source code the id value 'all-css-0', like i said you either loop through specific tag name

 

var x= document.getElementsByTagName('link');
for(var i=0; i<x.length; i++)
{
if(x[i].id===‘all-css-0‘)
{
alert('Look I found '+x[i].id);
}
}
OR ALL tag names

 

var x= document.getElementsByTagName('*');
for(var i=0; i<x.length; i++)
{
if(x[i].id===‘all-css-0‘)
{
alert('Look I found '+x[i].id);
}
}
This must be placed within a window.onload event in between <head> to </head> so it waits for elements to be fully rendered and exist before looping through them, OR placed as it is at the bottom before </body> closing tag. Edited by dsonesuk
Link to comment
Share on other sites


window.onload = function(){

 

var id = 'all-css-0';

 

if(document.getElementById(id))

{

var x = document.getElementById(id);

alert('A element of nodeName ' + x.nodeName +' does exist with id '+x.id);

}

else

{

alert('No element with id '+id+'exists');

}

 

}

Link to comment
Share on other sites

I will reformulate my question :

 

now I am in this page http://w3schools.invisionzone.com/index.php?showtopic=55183&hl=

 

and I want to find , in this page , an element by its id using

document.getElementById(id)

method . So how to do it ?

 

You want to get an element by its id.

 

What is the id of the element you want to find?

 

If you do not know the id, then you cannot find the element using this method.

 

"Get Element By Id" is equivalent to "Find Person By Name". If you do not know the name, you cannot find the person.

  • Like 1
Link to comment
Share on other sites

get an element by its id . If I do not know the id I cannot get its element . Totally logical and true Foxy Mod . Then how to get the id ? or what is the method used to get an id ? For example how to get the id in this page ?

Edited by hisoka
Link to comment
Share on other sites

You are supposed to know the ID of the element you want in advance.

 

Which ID do you want to get? There are many IDs on the page, if you don't know which one you want, then what are you trying to achieve?

  • Like 1
Link to comment
Share on other sites

The id has to exist before you can retrieve an id, its not hidden, you can plainly see ids applied to any elements by viewing the source on a page, the developer chooses what id to use, yes it could be dynamic, but it would follow some pattern to identify it, so you can access that element and manipulate that element or manipulate related parent, child elements. You do not have to target the element directly, you can use a known parent or child identifier id, class, attribute ( for instance img src attribute that could uniquely identify it), then transverse up through parents, or down through child elements, or transverse to sibling elements and transverse there child elements to reach the element you require. BUT! It does help to know what the you are looking for, that makes sense in the first place!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...