freecrm
New Member
- Messages
- 629
- Reaction score
- 0
- Points
- 0
This may be simple, it may not...
This is the process
1) Simple form
2) Dynamically generated (php) select menu with javascript onchange behaviour
3) onchange behaviour sends value currently in menu to a php page 2
4) page 2 creates mysql_result from query based on $GET value from main page 1
5) Main page 1 uses onreadystatechange to pull result from page 2 and display.
The current methodology uses the getElementById() to send result to a pre-specified div with that id.
What I want to do is to place that value into a form <textarea>
I can't place the whole <div id=" in a default value, so how can I achieve this?
Please understand that while my php skills are OK, my JS skills are not
Page 1 ajax code
Stripped down Page 1 html
Any ideas?
This is the process
1) Simple form
2) Dynamically generated (php) select menu with javascript onchange behaviour
3) onchange behaviour sends value currently in menu to a php page 2
4) page 2 creates mysql_result from query based on $GET value from main page 1
5) Main page 1 uses onreadystatechange to pull result from page 2 and display.
The current methodology uses the getElementById() to send result to a pre-specified div with that id.
What I want to do is to place that value into a form <textarea>
I can't place the whole <div id=" in a default value, so how can I achieve this?
Please understand that while my php skills are OK, my JS skills are not
Page 1 ajax code
Code:
var xmlhttp;
function GetInfo(str)
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
{
alert ("Browser does not support HTTP Request");
return;
}
var url="page2.php";
url=url+"?link="+str;
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
function stateChanged()
{
if (xmlhttp.readyState==4)
{
document.getElementById("ajax").innerHTML=xmlhttp.responseText;
}
}
function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
{
// code for IE7+, Firefox, Chrome, Opera, Safari
return new XMLHttpRequest();
}
if (window.ActiveXObject)
{
// code for IE6, IE5
return new ActiveXObject("Microsoft.XMLHTTP");
}
return null;
}
</script>
Stripped down Page 1 html
Code:
<form id="form1" name="form1" method="post" action="">
<label for="Example">Example</label>
<select name="Example" id="Example" onchange="GetInfo(this.value)">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<label for="FillIn">Text Area</label>
<textarea name="FillIn" id="FillIn" cols="45" rows="5"></textarea>
</form>
<div id="ajax">Default Primary Deck Spec will appear here.</div>
Any ideas?