HELP how to: Pass value from a form to iframe

kidcajes

New Member
Messages
21
Reaction score
0
Points
0
I have a payday.html with iframe in it:
HTML:
<html>
<body>

<iframe name="payday_info" src ="https://www.quote-advisor.com/iframe?i_type=payday&affid=8242&i_td1_color=bababa&i_td2_color=ededff&i_title_color=bfbfeb&i_submit_color=f0f0f5&i_width_td_left=20&i_width_td_right=80&i_width_table=100&i_align_left=&i_align_rigth=&subacc=1&i_width_table=100%" width="40%" height="460">
  <p>Your browser does not support iframes.</p>
</iframe>

</body>
</html>
in my index i need a textboxes for Name and Street Address and a Submit button. After the user enters the data and click the submit button it will open payday.html and displays the Name and Street Address in it.

Can anyone help me with the code i really cant figure it out, been trying reading other forums but no luck. I am new to iframe and haven't tried it before. Your help is greatly appreciated, TNX
 

ichwar

Community Advocate
Community Support
Messages
1,454
Reaction score
7
Points
0
Don't use iframes. Instead, use the php get() or post() function.
 

smithee

New Member
Messages
45
Reaction score
2
Points
0
iframe's are handy for when you want to display a new page in a portion of an existing page, so you still view the original one. Therefore you can seamlessly have the form on the same page as the iframe, and have it submit it like that.

It sounds like you want the form on the index page, and that leads to "payday.html" with an iframe... What will be in the iframe? The name and address? If so, why can't you put it on the same physical page as payday.html?

Oh yeah, and one final thing... a PHP page will be better instead of an HTML, so therefore it'll be "payday.php". Then it will be able to receive the data from the form via $_GET[] or $_POST[], like what ichwar has just said.
 

kidcajes

New Member
Messages
21
Reaction score
0
Points
0
Thank you very much guys for the suggestions. I understand that using php get and post is more appropriate to use. But i don't have a choice this is one of the assignment given to me by my professor.

I need solutions here. PLEASE if there is someone who can help me solve this. I greatly appreciate it, THANK YOU in advance
 

ichwar

Community Advocate
Community Support
Messages
1,454
Reaction score
7
Points
0
kidcajes, in that case, they you will have to use an iframe. Better yet, just tell your professor that iframes are clunky, messy and outdated, and that he shouldn't be making you use them when a php get() or post() will be so much simpler. ;)

On the practical side, I did do something like that once, but I had to use javascript to do it. Are you allowed to use javascript?
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
It's not really clear what you want to do.

You have "index", you have payday.html. You have an iFrame.

You want index.html with a submission form on it. Right?
Submitting the form will send you to payday.html which will have an iFrame it in. Right?
That iFrame will display the input from the form. Right?
 

ichwar

Community Advocate
Community Support
Messages
1,454
Reaction score
7
Points
0
It's not really clear what you want to do.

You have "index", you have payday.html. You have an iFrame.

You want index.html with a submission form on it. Right?
Submitting the form will send you to payday.html which will have an iFrame it in. Right?
That iFrame will display the input from the form. Right?
Yes, I think that's what he wants. As far as I know, the best way to do this is with cookies. I'd code the whole thing up for you kid, but I think that since this is your school, you would be better off doing it yourself so that you would learn how to do these things in the future. ;)

But I can help you with specific areas if you need help. Here's a good place to start: http://w3schools.com/js/js_cookies.asp
 
Last edited:

smithee

New Member
Messages
45
Reaction score
2
Points
0
Here's a little hint... to control iframe's from outside itself, give the iframe a name (which is "payday_info", so that's a good start) and any links/form buttons you want the page to load when the user clicks them, which is pretty obvious. To make it load into the iframe, you give the link/button a "target" variable which is assigned to the name of the iframe. For example:

HTML:
<a src="http://www.google.co.uk" target="payday_info">Click here to load Google into the iframe!</a>

Not giving too much away obviously ;)
 
Last edited:

kidcajes

New Member
Messages
21
Reaction score
0
Points
0
It's not really clear what you want to do.

You have "index", you have payday.html. You have an iFrame.

You want index.html with a submission form on it. Right?
Submitting the form will send you to payday.html which will have an iFrame it in. Right?
That iFrame will display the input from the form. Right?


Yes that is all i needed to do.
 

smithee

New Member
Messages
45
Reaction score
2
Points
0
Without PHP, there are two other alternatives I can think of:

  1. Using cookies
  2. Using the address bar

Both requires JavaScript to work. Here's how to create and read cookies:
http://www.w3schools.com/js/js_cookies.asp

And for using the address bar... make use of the hash symbol (#) to store "variables" similar to that of PHP, and get JavaScript to read the address bar.
 

ichwar

Community Advocate
Community Support
Messages
1,454
Reaction score
7
Points
0
Without PHP, there are two other alternatives I can think of:
Using cookies

Both requires JavaScript to work. Here's how to create and read cookies:
http://www.w3schools.com/js/js_cookies.asp
I already suggested that and I think it would be the easiest way.

Using the address bar

And for using the address bar... make use of the hash symbol (#) to store "variables" similar to that of PHP, and get JavaScript to read the address bar.
How is that done?
 
Last edited:

kidcajes

New Member
Messages
21
Reaction score
0
Points
0
36hrs before deadline and still no output. Waaa huhuhuhu, i am newbie after all. And this is my first web programming subject. Thanks in advance
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
What code have been you been able to write? Please give a minimal sample, leaving out styling and extraneous elements. What parts aren't working as you want them to? Are you dealing with an error?

Second Ichwar's opinion that the assignment is somewhat bogus in requiring both a result page and the iframe. Perhaps it's working towards illustrating how AJAX works in the absence of XMLHttpRequest, but requiring the "payday" page is a needless complication. Iframes are useful for cross domain scripting, but the assignment doesn't seem to be leading towards that.
 
Top