AleMonteiro 238 Can I pick my title?

alert the req.responseText and see what's coming

AleMonteiro 238 Can I pick my title?

Because the tutorial PHP page returns the entire select and not only it's options.

This works:

myDiv.innerHTML = '<select><option value=1>Option One</option></select>'

But this does not work:

mySelect.innerHTML = '<option value=1>Option One</option>'

The tutorial is using the first one, but your code is trying the second.

AleMonteiro 238 Can I pick my title?

To avoid conflict, use "JQuery." insted of "$."

AleMonteiro 238 Can I pick my title?

Use JQuery my friend.

They have the best selectors.

//To set the innerHTML of <li class="item31">
// # is the ID select
// . is the class selector

$('.item31').html('My new HTML');

JQuery it's a very useful JS lib, learn it and it'll save u time =)

Seeya.

AleMonteiro 238 Can I pick my title?

You are alerting "req.value", witch doesen't exists. And you cannot set a <select> innerHTML, you must add options to it.

The PHP page should return just the data, without the HTML. You could do it with XML, JSON or with your own syntax.

If you in the future need to use more data then just the value and the text, i recommed that you use JSON.

Just for the select you can pass the data like this: value|data||value|data
Here an example

<html>
	<script type="text/javascript">
		
	var strData = '1|Option One||2|Option Two';

	function parseData(data)
	{
		var select = document.getElementById("select");
		var arrData = data.split("||");
	   
		for(var i=0; i < arrData.length; i++)
		{
			var arrValues = arrData[i].split("|");
			select.options[i] = new Option(arrValues[1], arrValues[0]);
		}
	}
	
	window.onload = function()
	{
		parseData(strData);
	}
	</script>
	
	<body>
		<select id="select" size="1"></select>
	</body>
</html>
AleMonteiro 238 Can I pick my title?

It's possible if both page and iframe have the same domain.

You could do something like this, using JQuery:

<html>

	<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
	
	<script>
		//document ready
		$(function()
		{
			//inserts iframe
			$('<iframe src="page_test.htm" />').appendTo("body");
			
			//add load handler to iframe
			$("iframe").load(function()
			{
				//Get all links<a>, unbind the event onClick and set a new one
				$(this).contents().find("a").attr("onClick", "").click(function()
				{
					alert($(this).html());
				});
			});
		});
	
	</script>
	
	<body></body>
	
</html>

The iframe page is:

<html>	
		<script type="text/javascript">
			function openUrl(url)
			{
				alert(url);
				window.location = url;
			}
		</script>
	
	<body>
		<a href="JavaScript: void(0);" onClick="JavaScript: openUrl('page_test.htm');"> Click Me One</a> <br/>
		<a href="JavaScript: void(0);" onClick="JavaScript: openUrl('page_test.htm');"> Click Me Two</a> <br/>
		<a href="JavaScript: void(0);" onClick="JavaScript: openUrl('page_test.htm');"> Click Me Three</a> <br/>
	</body>
	
</html>

If your iframe is from other domain you wouldn't have access to do it, because browser security.

AleMonteiro 238 Can I pick my title?

Just an idea for you to test:

elem2.style.opacity = parseFloat(elem2.style.opacity) + interval;
AleMonteiro 238 Can I pick my title?

There is a lot of ways you can do that, one of them is:

<html>
	<head>
		<title>JavaScript Window Open/Close Example </title>
	</head>

	<script type="text/javascript">
	   
		var my_window;
	   
		function popuponclick()
		{
			my_window = window.open("",	"mywindow","status=1,width=350,height=150"); // Open window
	 
			if (my_window.opener == null) // Set opener window of the child for compatibility issues
				my_window.opener = self;
	 
			my_window.document.write // Insert content in the child (so i don't have to create an b.html)
			(
				'<input type="text" id="my_window_text" value="" />' +
				'<a href="javascript: opener.updateAndClose();">OK</a>'
			);
		}
	 
		function updateAndClose()
		{
			document.getElementById("my_text").value = my_window.document.getElementById("my_window_text").value; // Set the parent window text input with the child window text input value
			my_window.close(); // close child window
		}
		
	</script>
	
	<body>
		  <a href="javascript: popuponclick()">Open Popup Window</a>
		  
		  <br/>
		  
		  <input type="text" id="my_text" value="" readonly />
		  
	</body>

</html>

Base example from: http://www.javascript-coder.com/

Hope it helps, and if it does, please set it as an answer.

localp commented: Was googling this for weeks, and i finally found it. +0
AleMonteiro 238 Can I pick my title?

Hi, normally it should have an = yes, but using JQuery we use methods to set values. And in methods, the value is passed in ();

Just to be explict, the jquery.js needs to be on the same folder as the html.

Here's the working example:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<LINK REL=StyleSheet HREF="style.css" TYPE="text/css">

<style>
	#indexcontent{
	background-color:#336699;
	border-top:#2175a5 solid 10px;
	padding:10px 10px 10px 10px;	
	display:inline;
	position:relative;
	width:421px;
	float:left;
}
	
#indexblog {
	background-color:#3333FF;
	border-top:#2175a5 solid 10px;
	padding:10px 10px 10px 10px;	
	position:relative;
	width:421px;
	float:left;
	margin-left:100px;
}

</style>

<script type="text/javascript" src="jquery.js"></script>

<script>


// Tell the browser to execute fixHeights when the document is ready

$("document").ready(fixHeights);

function fixHeights()
{
	// Get elements reference

	var content = $("#indexcontent");
	var blog = $("#indexblog");

	if ( content.height() > blog.height() ) // Compare the heights
	{
		blog.height(content.height());
	}
	else
	{
		content.height(blog.height()) ;
	}
}


</script>


</head>


<body>


<div id="column-container">

 <div id="indexcontent">dwqdwqf<br>
 dnjkwlka<br>
 dsadsa<br>
 daDASDS<br>
 dsadsadas<br></div>
 <div id="indexblog">dsadfw<br>
 few<br>
 fe<br>
 wf
 ew
 few
 f
 ew
 few
 few
 </div>

</div>




</body>
</html>
AleMonteiro 238 Can I pick my title?

Hi, you should use JQuery to make it easier.

<script type="text/javascript" src="jquery.js"></script>

With JQuery the folliwing script should work:

// Tell the browser to execute fixHeights when the document is ready
$("document").ready(fixHeights);

function fixHeights()
{
	// Get elements reference
	var content = $("#indexcontent"); 
	var blog = $("#indexblog");
	
	
	if ( content.height() > blog.height() ) // Compare the heights
	{
		blog.height(content.height());
	}
	else
	{
		content.height(blog.height()) ;
	}
}

http://jquery.com/

It should work but i recommend you to study a little about javascript, it can be very usefull.

AleMonteiro 238 Can I pick my title?

Hi, you should use JQuery to make it easier.

<script type="text/javascript" src="jquery.js"></script>

With JQuery the folliwing script should work:

// Tell the browser to execute fixHeights when the document is ready
$("document").ready(fixHeights);

function fixHeights()
{
	// Get elements reference
	var content = $("#indexcontent"); 
	var blog = $("#indexblog");
	
	
	if ( content.height() > blog.height() ) // Compare the heights
	{
		blog.height(content.height());
	}
	else
	{
		content.height(blog.height()) ;
	}
}

http://jquery.com/

It should work but i recommend you to study a little about javascript, it can be very usefull.

AleMonteiro 238 Can I pick my title?

Just set type="button"

<input type="BUTTON" name="ConfirmBooking" id="ConfirmBooking" value="Confirm Booking" onclick="Accept()" />

When using input for buttons, use onClick event for type="button" and onSubmit for type="submit"(in this case, the listener must return false for canceling the submit).

Hope it helps.