i am developing a web tracker for my site, and one of the ways i am transferring data, is by auto-filling form data on page load, with javascript queries being used to fill each field…..
i just need strings of text to be transferred from the form to another php script…..
this side of it is easy…..
the form ( and data collected on page load ) is hidden in an invisible iframe, so that it can do its work in the background….
i need the url of the main page (not the iframe) to be auto inserted into one of the form fields…..
heres what i have so far,,,,
this is the code that is displayed on parent page (in this example “events”):
<iframe src="/track/track.html?events" height="500" width="500" scrolling="no" border="0"></iframe>
i know i said invisible iframe, the 500×500 size is so i can see behind the scenes while developing….
then in the iframe the code i have is :
<?php
$ip = $_SERVER['REMOTE_ADDR'];
$my_t = getdate(date("U"));
$url = $_SERVER['REQUEST_URI'];
?>
<html>
<body>
<form action="/track/location.php" method="post">
<input type="text" name="time" value="<?php echo "$my_t[weekday], $my_t[month] $my_t[mday], $my_t[year] - $my_t[hours]:$my_t[minutes]:$my_t[seconds]" ?>">
<input type="text" name="ip" value="<?php echo $ip ?>">
// script A //
<script type="text/javascript">
document.write(window.location.search);
</script>
// end script A //
// script B //
<script>
var url = ['alert(window.location.search)'];
document.write("<input type=\"text\" name=\"url\" value=\"" + url + "\">");
</script>
// end script B //
<input type="submit" name="submit" value="submit">
</form>
script A will produce a statement of text “?events” where inserted as “document.write”
script B will produce a text box with the text “alert(window.location.search)” pre inserted as a value…. which is kind of what i want…..
i basically need to be able to combine script a and b so that it will write the (window.location.search) data (“?events”) in the text box instead of the plain text java command….
i will be very greatful if anyone can help me, thanks in advance guys 🙂
Is this what you want?