Jump to content
Sign in to follow this  
razi89

Help..I m new to this stuff

Recommended Posts

I am a beginner and i want to design a website for other students like me . The website is about quizzes like in which u got a question and multi option,select right one .. that stuff .

My plan is to make a main page "container.html" which contains a iframe and a button .Iframe will be used to display quiz pages "Q1,Q2,etc." and the button to change "ifame src= "" and submit the answer for example- Q1.html is loaded in frame,a person solves the quiz press the button then his answer is stored and next quiz Q2.html is loaded into frame . I have made Q1,Q2 pages with php and tested they work fine and also the made website's layout with that button.Problem is the button uses javascript to change the iframe "getdocumentbyId" and the quiz pages are made with html form and uses php to process data . So when i click button the iframe source can change but the form(Q1) data is not submitted to php because the submit button is on differnt page(container.html) . I have basic knowledge of javascript and some better about php so guyz please make this easier for me .I have learned all that i know from w3schools so i know here's a hope of solution . Thankz !

post-176501-0-87063100-1411232342_thumb.jpg

Share this post


Link to post
Share on other sites

Please show us some code and we'll help you with it

  • Like 1

Share this post


Link to post
Share on other sites

It's hard to understand your question. If your iframe has a name you can use the form's target attribute to make the form submit to that iframe:

<iframe name="frame"></iframe><form target="frame" action="action.php">
  • Like 1

Share this post


Link to post
Share on other sites

You first need to wrap your <submit> button in a form. The form attribute has to point to an existing form, the formaction and formmethod attributes are only there to set or change the value a form element that already exists.

 

As I mentioned in my previous post, the <iframe> has to have a name, and then you can use the target attribute of the form to make the form submit to that frame.

<iframe id="frame1" name="frame1" src="Q1.php" align="left" height="400" width="450" scrolling="no" ></iframe><!-- target="frame1" tells the form to submit to the iframe element --><form action="score.php" method="POST" target="frame1">    <div><input name="submit" type="submit" id="butt"  value="SUBMIT"></div></form>
  • Like 1

Share this post


Link to post
Share on other sites

thanks for all help but those answers didnt solved my problem ,here is a same scene :http://codingforums.com/javascript-programming/32945-how-write-html-code-iframe-parent-document.html .

i am continuously searching for the solution and in the mean time i learned basics of javascript and jquery.recently i found a trick that solved my problem here is a code of my trial :

// JavaScript Document$(document).ready(function() {	var x ;$("#button").click(function() {	x = $("input[name=roption]:checked").val()$.post("score.php",{'user':x},function (data){	if (data ==""){var y;}	else {	$("#con_frame",parent.document).attr("src","q1.html");	$("#main_sec",parent.document).html(data);	$("#u8").html("changed");	}	})});}); 

can anyone tell me where can i know more about "parent.document" ?? because its not working in IE8.ALSO can i do similar action without javascript or jquery bcoz sometimes they are disabled ?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×