Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-05-2010, 09:02 PM   PM User | #1
forums.siva
New to the CF scene

 
Join Date: Jul 2010
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
forums.siva is an unknown quantity at this point
AJAX: Pass vale to Server from Javascript

Hello

I am using PlainAjax. http://coolpenguin.net/plainajax/?p=examplespostdata

Here is my code and it is not working if i called from Javascript function.

Code:
<script type="JavaScript" src="plainajax.js"></script>
<script language="JavaScript" >

function openWin()
{
	.......		
	.......
	.......
	var selval = selectedValue.toString();	 	// Dynamic value variable
	document.formlist.myval.value = selval; 	// stored to hidden variable

	
	 var cn = document.getElementById( "itsme" ).childNodes;	// Get all the nodes
	
	 var myresult = new Array();					// declare result array
    	 plainajax.request('respurl: req_php.php; resultloc: myresult; paramloc: cn;');
  
	 Window.open("req_php.php");
	
}

</script>

<html>

 <div id="itsme">

	<input type="hidden" name="myval" id="myval" value=""> 
</div>

</html>

req_php.php
=========
Code:
<?php

		echo "value from html = ".$_REQUEST['myval']."<br>";
	
?>


But i am not able to get any value in my php program. What i did wrong in this?

or is anyother way to pass the variable from Javascript (except pass thru url query string, this is not secure)

Thanks
forums.siva is offline   Reply With Quote
Old 07-05-2010, 11:02 PM   PM User | #2
byuhobbes85
Regular Coder

 
byuhobbes85's Avatar
 
Join Date: Oct 2006
Location: Ames, Iowa, USA
Posts: 116
Thanks: 9
Thanked 4 Times in 4 Posts
byuhobbes85 is an unknown quantity at this point
Your input is a hidden input, which means the user can't alter it. Since that hidden input is an empty string, your PHP script is probably printing out the correct value--an empty string (which prints nothing on the screen).
__________________
-- </byuhobbes>
byuhobbes85 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:13 AM.


Advertisement
Log in to turn off these ads.