Fill the input with text extracted out of the xhtml page

Discussion in 'JavaScript' started by pozer, Jul 25, 2010.

  1. #1
    I have an input field on the page, and I have the text written somewhere on the page: "Your desired domain is www.domainname.com." Domain name is dynamic text, every time something else.

    I would like to automatically fill the input field with "domainname" while tld can be anything (.com, .net, .name, ...). How can it be achieved with JavaScript or jQuery? It is not possible server-side, it has to go like this.
     
    pozer, Jul 25, 2010 IP
  2. Deacalion

    Deacalion Peon

    Messages:
    438
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #2
    1. Use JQuery selectors to grab the inner html of the element that contains the text "Your desired domain is www.domainname.com"
    2. then perform a regex on that string to extract the domain name
    3. assign the domain name to the input text field using JQueries .val()
     
    Deacalion, Jul 25, 2010 IP