Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem opening popup window and passing it value

Status
Not open for further replies.

Edward07

Programmer
Apr 13, 2007
49
NL
I am passing a javascript function values from checkbox and textbox.
The problem is that when click the button instead of opening script.php in a popup window
it redirects to script.php page.Also i don't know how to pass value of + url to script.php
popup page so it can use it. could any one tell me what i am doing wrong here.Thanks


Code:
//want to open a popup window and pass it value of url
 url2 ='[URL unfurl="true"]http://localhost/script.php';[/URL]
 name = 'chat';
 var params = 'width=472,height=320,menubar=no,scrollbars=0';
 var ow = window.open(url2, name, params);



Code:
<script>

function talktoServer(){
    var req = newXMLHttpRequest();
	//register the callback handler function
  	var callbackHandler = getReadyStateHandler(req, updateMsgOnBrowser);
  	req.onreadystatechange = callbackHandler;
  	//req.open("POST", "servertime.php", true);
  	req.open("POST", "engage3.php", true);
  	req.setRequestHeader("Content-Type", "application/x-[URL unfurl="true"]www-form-urlencoded");[/URL]
  	//get the value from the text input element and send it to server

//geting textbox data this next line
var text = document.getElementById('testmsg').value;
alert("textdata:"+text);

totalvotes = document.forms.mp3Play.totalvotes;
alert("checkboxvalue:"+totalvotes);

tempUrl ='';
url = '';

if (totalvotes.length > 0){  
 for (i=0; i<totalvotes.length; ++ i)
 {
	 if (totalvotes[i].checked)
	{
		tempUrl =tempUrl  + totalvotes[i].value +","
		if (i == 30)
		{
			alert("Each time you can only select 30 songs to play")
			return false;
		}
	}
 }
}
else
	{
		alert("it is less than 0#2")
		tempUrl = tempUrl + "&totalvotes=" + totalvotes.value
                

	}



	
        req.send("msg="+ url +"&text="+ text);

//want to open a popup window and pass it value of url
 url2 ='[URL unfurl="true"]http://localhost/script.php';[/URL]
 name = 'chat';
 var params = 'width=472,height=320,menubar=no,scrollbars=0';
 var ow = window.open(url2, name, params);
}

</script>

    <div id="Last5Songs" style="WIDTH: 888px; HEIGHT: 39px">
    
          <input type="checkbox" value="83b8e68c1605a2b71fead4cd64c166c9" name="totalvotes"></div>

<input id="testmsg" type="text" value="Hello">
<button id="playSelected" onclick="talktoServer()">Engage</button>&nbsp;&nbsp;&nbsp;&nbsp;
 
In the PHP file, I'm sure there are ways of getting the current URL (possibly something like:

Code:
$_SERVER["SCRIPT_NAME"]

(although I'ml no PHP guru, so best to ask in the PHP forum for this one).

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Hmm- OK - that only gives the filename, not the whole path. You'd really need to take this to the PHP forum to find out how to get the whole URL.

Or... you could pass it as a parameter, but as you'd still want to pick up on it in PHP, this is pretty much pointless.

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
How to make the the window pop up instead of redirecting to that page. i have used this code:

//want to open a popup window and pass it value of url
url2 =' name = 'chat';
var params = 'width=472,height=320,menubar=no,scrollbars=0';
var ow = window.open(url2, name, params);

in the past to pop up window but it doesn't work in above setup. i think this problem is javascript not php . I know now how to pass value to php so that is not problem !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top