Is it possible?!

Discussion in 'Programming' started by indodave, Dec 3, 2006.

  1. #1
    Is it possible to prepopulate a thirdparty form field through the use of javascript or someother web based script?

    For instance being able to load http://www.google.com and have the search box prepopulated with a specific term?

    What I am trying to achieve, is to be able to send visitors from my site to another site (third party) and have a form pre populated with specific information.

    So can this be done with javacript hidden in frames or something? or can it be done in the address bar? - clutching here!

    FYI - I cannot edit the thirdpartys HTML code.

    Cheers
    Dave
     
    indodave, Dec 3, 2006 IP
  2. papa_face

    papa_face Notable Member

    Messages:
    2,237
    Likes Received:
    67
    Best Answers:
    1
    Trophy Points:
    285
    #2
    If you want to go to google.com and put a specific term in THAT search box, the answer to your question is no.
    However, you can quite easily make a script that would put the search term in the google address.

    I made this:
    
    <?php
    
    if (isset($_POST["submit"]))
    	{
    	$search = ereg_replace(" ","+",$_POST["search"]);
    	$google = "http://www.google.com/search?hl=en&q=" . "$search"; 
    	header('Location:' . $google);
    	}
    
    else
    	{
    	echo	"<form action=\"".$_SERVER["PHP_SELF"] ."\" method=\"post\" enctype=\"multipart/form-data\">
    			<input name=\"search\" type=\"text\" />
    			<input name=\"submit\" type=\"submit\" />
    			</form>";
    	}
    
    ?>
    Code (markup):
    It will do what you want, i think... :)
     
    papa_face, Dec 3, 2006 IP
  3. indodave

    indodave Active Member

    Messages:
    18
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    86
    #3
    That's not really waht I was looking for....

    What I was basically looking for was more of a web based roboform.com type application.

    which could be hidden in frames around the real site and populates the form fileds.

    Dave
     
    indodave, Dec 3, 2006 IP
  4. klown

    klown Peon

    Messages:
    2,093
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I'd be willing to pay for something that does this, i posted a similar want ad a while back nobody said they could do it.
     
    klown, Dec 3, 2006 IP
  5. papa_face

    papa_face Notable Member

    Messages:
    2,237
    Likes Received:
    67
    Best Answers:
    1
    Trophy Points:
    285
    #5
    That is a plugin for browsers. There is no way you can get an script to do that. The script I made is your only option.

    EDIT: Actually they may be a way you can assign a value to the search box in a frame. I dont know how it would be done though. I will have a play around with PHP.
     
    papa_face, Dec 3, 2006 IP
  6. klown

    klown Peon

    Messages:
    2,093
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    0
    #6
    PHP wouldn't be able to do it, not sure about javascript. I'm sure an extension for firefox would work fine.
     
    klown, Dec 3, 2006 IP
  7. papa_face

    papa_face Notable Member

    Messages:
    2,237
    Likes Received:
    67
    Best Answers:
    1
    Trophy Points:
    285
    #7
    Yeah, i agree.
    However the OP wants something in the browser.
    I still dont see why the code I suggested wouldnt suffice. All the user would be gaining by doing it the suggested way, would be actually seeing the google page instead of just the results...
    The reason why the suggested way wont work, is because the server would be attempting to modify a value for a page it doesnt have access to, in order to modify.
    The only way the suggested way could be done, is if google has some sort of feature that allows values to be passed to their homepage (which im not aware of).
     
    papa_face, Dec 3, 2006 IP
  8. TwistMyArm

    TwistMyArm Peon

    Messages:
    931
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #8
    devnerd: I believe the Google scenario was just an example and that indodave is really after a generic 'Third Party Site Form Filler'.

    I know of no way for JavaScript to do it. In theory, JavaScript is not meant to be allowed to interact at all with pages from another domain.

    I think that yes, you need to look into browser plugins. GreaseMonkey scripts are technically Firefox 'plugins' but are written in JavaScript I believe. I've never used it, but I do know that it's used in cases like you have mentioned.
     
    TwistMyArm, Dec 4, 2006 IP
  9. wmtips

    wmtips Well-Known Member

    Messages:
    601
    Likes Received:
    70
    Best Answers:
    1
    Trophy Points:
    150
    #9
    You can modify form field contents with JS if you open 3rd party page within your page (in frame or iframe). If such a page will be opened in the new window, you cannot interact with it without browser plugin (greasemonkey etc.)
     
    wmtips, Dec 4, 2006 IP
  10. indodave

    indodave Active Member

    Messages:
    18
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    86
    #10
    That's what I was wondering... basically if I open another site up in a frame or something. Could I then use javascript to auto insert information into the thirdparty sites form fields?
     
    indodave, Dec 4, 2006 IP
  11. CodyRo

    CodyRo Peon

    Messages:
    365
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Hmm, not sure if I get what you want to do fully but couldn't you do something along the lines of: grabbing the source of the site (file(), etc) iterate through it and extract the form details (regexp).. from there you could assign values to each form name and use cURL to submit.

    (If that made any sense)
     
    CodyRo, Dec 4, 2006 IP
  12. indodave

    indodave Active Member

    Messages:
    18
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    86
    #12
    That really depends on what you are trying to achieve in the thirdparty site. If the site has tracking via cookies or some other factors, they might get missed. So that is why I was looking to just open the thirdy party site via frames or iframes and then insert the data into fields.

    thanks eveyone!
     
    indodave, Dec 4, 2006 IP