typing in string values in html form fields

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • questionit
    Contributor
    • Feb 2007
    • 553

    typing in string values in html form fields

    Hi

    I am trying to write a code in HTML , maybe will use javascript if required. The code will open a webpage and type in username and password in the fields automatically and click the submit button.

    The page i wish to work on put the cursor in the first field by default.

    So i just need to type in the string values into these fields.

    Please help as to how to proceed. Is it possible to do it in HTML alone?

    Thansk a lot

    Qi
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5390

    #2
    i doubt that this could be done without javascript ... you need to focus() the fields what you could do with simple javascript.

    kind regards

    Comment

    • drhowarddrfine
      Recognized Expert Expert
      • Sep 2006
      • 7434

      #3
      Yes. Javascript must be used.

      Comment

      • questionit
        Contributor
        • Feb 2007
        • 553

        #4
        Thanks a lot for answers

        Could anyone direct me how to do it in javascript.

        I know javascript to beginners level. As i said in my post, when the webpage opens, the cursor is in the right field already. Now how to type in something in that field. What javascript method shall i use?

        Also, just in case, whats the function to bring focus onto a different field, is it just focus() ?

        Thanks
        Qi

        Comment

        • gits
          Recognized Expert Moderator Expert
          • May 2007
          • 5390

          #5
          just one more question before we proceed. is that page where you want to have the field 'autofilled' from your domain? what is the purpose of that all ... because in case you need to fill in values across domains then i just have to say that this would be only possible with additional serverside handling ...

          in case you need more information regarding that ... then you should ask a mod in the html-forum to move this thread for you over to the JavaScript-forum ... or just post a new one there ... so that other users may find that such problems involve JavaScript at least.

          kind regards

          Comment

          • questionit
            Contributor
            • Feb 2007
            • 553

            #6
            yes the page is not in my domain, its an external page (customer logon page of my internet.servic e provider)

            i was thinking of copying and saving all the source code of that page and then make changes , additions to get this done.... and when it will have been done, i will click on the saved file (it will be a HTML file) , and the page will open up with the fields filled in. could this be done?

            I have read the source code of that page, it is only HTML with javascript.

            Thanks
            Qi

            Comment

            • acoder
              Recognized Expert MVP
              • Nov 2006
              • 16032

              #7
              Moved to JavaScript forum

              --Moderator.

              If all you want to do is have the fields auto-filled, you can use the feature in your browser (where it remembers the password), or use a program like Roboform.

              Comment

              • gits
                Recognized Expert Moderator Expert
                • May 2007
                • 5390

                #8
                in this case you just need to use the local copy and write the username and password to the value attrib of the corresponding textfields ... and the only thing you need to do would be to click the submit button ... you could even trigger a function onload of the local-page that submits the form (you may use the submit() function of the form-element) ... may be additionally you need to adapt some urls from relative to absolute ones ...

                kind regards

                PS: or use acoders hint and just use the browser feature ...

                Comment

                • phvfl
                  Recognized Expert New Member
                  • Aug 2007
                  • 173

                  #9
                  To execute the Javascript it would need to be run on the page in question. Since this is not one of your pages you would need to inject the Javascript. The easiest way to do this is to write a userscript and use GreaseMonkey for Firefox. An alternative for IE is called Trixie although I have not used this for a number of years.

                  If the information is posted on the page using a GET request the easier method of doing this would be submit a request with the information already within the request e.g "www.some.domai n.com/login.aspx?user name=foo&passwo rd=bar".

                  If the page uses a POST request then you would need to make a HTTP POST request. Although this also may not work if the page does validation to ensure that the request was submitted directly from their page.

                  Comment

                  • gits
                    Recognized Expert Moderator Expert
                    • May 2007
                    • 5390

                    #10
                    when the page runs locally you could easyly modify the javascript in it without any injection or whatever. the page just needs to ensure that the form is send to the correct address ... or do i miss something here? ... besides any validation logic the serverside might do ... of course.

                    kind regards

                    Comment

                    • phvfl
                      Recognized Expert New Member
                      • Aug 2007
                      • 173

                      #11
                      I thought that the pages were not local as the OP said that they were not on their domain

                      Originally posted by questionit
                      yes the page is not in my domain, its an external page (customer logon page of my internet.servic e provider)
                      I suppose that this could be run through a "javascript:... " entered in the location bar.

                      I could also be totally misunderstandin g and talking gibberish :)

                      Comment

                      • questionit
                        Contributor
                        • Feb 2007
                        • 553

                        #12
                        Thanks all for replies

                        The webpage in question doesn't have 'remember me' kind of thing on it , not does IE remembers anything .. I think Firefox has extra capability to remember ID/Passwords and it may or maynot work in my case but i dont want to use Firefox.

                        Further to your technical replies, could anyone direct me to the functions i needto write that will fill in the fields automatically.

                        Before we could talk about writing code, how would i determine the fields' name on that page? I think Dreamweaver tell syouwhen you click on any object, it is highlighted in the source code which object you click on.

                        I am not willing to buy or download heavy downloads of Dreamweaver, so i would be thankful for someones further help in it.

                        As to Roboform, is it safe, i mean passwords saved in it can be stolen all at once? If yes, is there any freeware you similar to this?

                        My preference is to write my own code instead, so assuming i know the name of the fields on that page. I need to use onPageLoad or onPageOpen (are there any such functions in javascript?) , if yes what r these?

                        Thanks
                        Qi

                        Comment

                        • gits
                          Recognized Expert Moderator Expert
                          • May 2007
                          • 5390

                          #13
                          if you have saved the file locally you just need a texteditor to view the sourcecode ... now search for something like:

                          [code=html]
                          <input type="text" name="some_name _of_the_user_fi eld"/>
                          [/code]
                          there you just need to add the value like this:

                          [code=html]
                          <input type="text" name="some_name _of_the_user_fi eld" value="foo"/>
                          [/code]
                          do the same for the passwordfield and use your credentials. now save it and open it in the webbrowser ... now you should see foo typed in. now press the submit button and see whether it works or not. in case it works then you could add a function that is called onload of the page and that submits the form instantly. but first try to find the fields and check whether it would work locally.

                          kind regards

                          Comment

                          • gits
                            Recognized Expert Moderator Expert
                            • May 2007
                            • 5390

                            #14
                            Originally posted by phvfl
                            I thought that the pages were not local as the OP said that they were not on their domain
                            i thought in post #6 the OP told that he wanted to just save the page locally and modify it to his/her needs?

                            kind regards

                            Comment

                            • questionit
                              Contributor
                              • Feb 2007
                              • 553

                              #15
                              Thanks for replies

                              I have found the fields name with your help and have populated fields' value also.

                              Now before i write onLoad function, i am facing another problem:

                              When i manually click on 'Submit' button, nothing happens. The reason is that i have saved the source code of the original page on my C drive and when 'Submit' button is clicked, this URL is loaded:

                              [code=text]
                              C:\Documents and Settings\Privat e\Desktop\Login .aspx
                              [/code]


                              The page uses POST method. When i open the URL, here
                              http://0.0.0.0/SelfCare/Dashboard.aspx ----0.0.0.0 is not real IP

                              I have found this from the code:
                              <form name="form1" method="post" action="Login.a spx" id="form1">

                              How can i make the submit button to open the actual page ?

                              Thanks
                              Qi

                              Comment

                              Working...