0

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 :)

2
Contributors
9
Replies
10
Views
8 Years
Discussion Span
Last Post by Thirusha
0

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 :)

0

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.

0

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?

0

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.

0

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?

0

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.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.