hello all, i am new to ajax.. unfortunately, i was given an assignment before i complete ajax.. i need help, someone pls direct me where i can learn to solve the following thing!!

Consider a web page has 3 frames, the top has the header, the left has the actions in a tree, and the right is the functional frame. In the top of functional frame i need to add another frame, in which all the messages can be displayed. i.e when I want to show a failure message to the user for the validation done on the inputs given, instead of an alert popping up, I can display the message on that frame which stays for a few seconds.

any kinda tips would be of much help to me.
thanks :)

Recommended Answers

All 9 Replies

Have u been able to come up with anything?
Ajax isnt difficult. try w3schools' website.

commented: Thanks girl +1

i didnt figure this out yet.. :(

Start with the basics, create a page with three frames.
Then go to http://www.w3schools.com/Ajax/ajax_example.asp, play around with the example.

You can use the same ajax code that is provided on that site, and incorporate it into the page with the three frames.

hey thirusha..
thanks for the heads up.. i solved half..

i created frames, validated the input..
now, i need to send the output of that validation to the next frame..
any resource would be of great help :)

in the ajax function, where you process the response, you will set the innerhtml of that frame to be the response.
something like this,

document.getElementById('frameId').innerHTML = req.responseText

You can post the code that u have so far, and i shall take a look.

actually, i did it with javascript itself.. :|
here's my two frames codes..

Actions.html
<html>
<body>
<p>This is Actions Frame</p>
<br />
	<form name="validate" method="post"  > <!-- onsubmit="valtext(this)" -->
	<input type="text" name="username" />
	<input type="submit" value="submit" onclick="parent.passvalue(this.form.username.value);" />
	</form>

</body>
</html>

Functions.html
<html>
<head>

<script type="text/javascript">
function validate(name)
{
 if(name.username.value == "")
 {
  alert("Form is not filled");
  return false;
 }
 else
 {
  return true;
 }
}
</script>

</head>
<body>
<form name="funcform">
<input type="text" name="functext" onchange="validate()"/>
</form>
<p>This is Functional Frame</p>
</body>
</html>

with this function in my frameset.html

function passvalue(val)
{
 top.frames['func'].document.funcform.functext.value=val;
}

now what i am unable to do is that i cant validate the input filed that i sent.. i.e, the 'Validate' function in 'Function.html' is not working..

also, is there a way to display the validation result only for a few seconds?

I think you should change the button on the Actions.html page from a type submit to a type button, then add an onclick event, this way it will let u know if something is wrong, with a type submit, the page will always submit.

I played around with the code u provided, and i think u should change the following on the Actions.html page, add the function that u validate the input, and change the button to this:

<input type="button" value="submit" onclick="valtext(document.getElementById('username').value)" />

<script>
function valtext(val)
{
 if(val == "")
 {
  alert("Form is not filled");
  parent.FrameSet1.document.getElementById("ff").innerHTML = "Form is not filled";
  return false;
 }
 else
 {

  return true;

 }
}
</script>

I added a div tag to the FrameSet.html page.

You were on the right track, the reason for your function not working was that the function required a variable to be passed to it, which you didnt supply.

What helps alot when coding in javascript in Firefox's Firebug, try and get it.

Oh.. tat works fine.. thanks :)
and btw, do you have any idea of how to display the result for a particular time period instead of an alert?

It would work in the same way as above, that is place the response in an area on the page.

Remember to mark the thread solved once your question is answered so that other users dont reply to a thread that is in fact solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.