Hi, I need to fill form fields with values (Opera).
I want it to work like this:
The users on my website are already registerred, so I know theire name and email adress.
I want my users to be able to vote on a form (offsite).
The form is kaptcha protected, so regarding abuse/spam on my form, it's not vital, as they will have to manually type in the kaptcha image-text and press the submit.
I will have the offsite-form inside an iframe.
You might ask: whats the point..
Well, we have this game.. monopoly, and all cities have to vote for theire city to be entered in the game.. so I want to increase how easy it will be to vote for my city!
So, I will have the users username parsed in hidden input fields..
In the source I paste here, it will be text-fields, but when the JS works as I want, I will make it more dynamic (php / mysql and parse input hidden).
Anyhow: here is my HTML code
I have removed the reference to the other site, but if I take view-source, the inputs are like:
So, I need to reference that input, inside the IFRAME and fill that field here with the data from the field outside of the IFRAME.
I have to do it in Opera too, as I have to disable flash to get to the HTML input and this is very easy to do in Opera.
Hope someone can help me
PSUEDOCODE for what I need:
Where subpage is the iframe...
Olav Alexander Mjelde
Admin & Webmaster
I want it to work like this:
The users on my website are already registerred, so I know theire name and email adress.
I want my users to be able to vote on a form (offsite).
The form is kaptcha protected, so regarding abuse/spam on my form, it's not vital, as they will have to manually type in the kaptcha image-text and press the submit.
I will have the offsite-form inside an iframe.
You might ask: whats the point..
Well, we have this game.. monopoly, and all cities have to vote for theire city to be entered in the game.. so I want to increase how easy it will be to vote for my city!
So, I will have the users username parsed in hidden input fields..
In the source I paste here, it will be text-fields, but when the JS works as I want, I will make it more dynamic (php / mysql and parse input hidden).
Anyhow: here is my HTML code
Code:
<html>
<head>
<title>IFRAME test </title>
</head>
<body>
<form name="PForm">
First Name <input type="text" value="Firstname" name="FirstName" size=30>
Last Name <input type="text" value="Lastname" name="LastName" size=30>
</form>
<div id="FullName">Type in your name and click on the button below to see the example of doing an ajax style partial page update using an iframe.</div>
<script language=javascript>
var IFrameDoc;
window.opener = window;
function LoadIFrame()
{
var myDiv = document.getElementById('FullName');
myDiv.innerText = "";
IFrameDoc = window.open("[URL unfurl="true"]http://www.xxxx.xx/vote.aspx",[/URL] "SubPage" /* target */, "");
IFrameDoc.opener = window;
}
function SubWindowLoaded(SubForm)
{
var pform = document.PForm;
var fname = pform.FirstName.value;
var lname = pform.LastName.value;
alert(fname);
/* fill form values with data */
SubForm.FirstName.value = fname;
SubForm.LastName.value = lname;
SubForm.ctl00$CPHRight$uclVoteHtml$txtYourEmail.value = fname;
}
</script>
<button onClick="LoadIFrame();">Load Page</button>
<button onClick="SubWindowLoaded('aspnetForm');">Fill Form</button>
<hr>
<iframe name="SubPage" width="830px" height="600px"> </iframe>
</body>
</html>
I have removed the reference to the other site, but if I take view-source, the inputs are like:
Code:
<input name="ctl00$CPHRight$uclVoteHtml$txtYourName" type="text" id="ctl00_CPHRight_uclVoteHtml_txtYourName" style="width:250px;" />
So, I need to reference that input, inside the IFRAME and fill that field here with the data from the field outside of the IFRAME.
I have to do it in Opera too, as I have to disable flash to get to the HTML input and this is very easy to do in Opera.
Hope someone can help me
PSUEDOCODE for what I need:
Code:
SubPage.getelementbyid(ctl00_CPHRight_uclVoteHtml_txtYourName).value = pform.LastName.value;
Where subpage is the iframe...
Olav Alexander Mjelde
Admin & Webmaster