PDA

View Full Version : Anyone knows how to get the input value



che_anj
Sep 7th, 2007, 12:28 PM
hello,

could anyone has idea how to get the input value of the inputbox by clicking the button and the value of the textbox must be pass to the popup window page..

heres my code ...

<input type="text" name="compname">


<?php echo "<input type='button' name='ser' value='Search' onclick= \"return popitup('jobpicker.php?empid="$_POST[compname] "')\">";?>


tnx

Kor
Sep 7th, 2007, 12:53 PM
we need to see the popitup() function...

che_anj
Sep 7th, 2007, 01:04 PM
<SCRIPT LANGUAGE="JavaScript">
function popitup(url)
{
newwindow=window.open(url,'name','height=200,width=670, left=250, top=200');
if (window.focus) {newwindow.focus()}
return false;
}
</script>

Kor
Sep 7th, 2007, 01:10 PM
Ok, now tell us where that value should be passed in the popup window. In a textbox there? Which is the name/id of that element? Or as text? Where?

che_anj
Sep 7th, 2007, 01:17 PM
the value of the textbox should be pass to the popup window.

example of If i have to type "FRS" in the textbox, when I click the button a popup window wil execute at the same it gets the value of the textbox.

che_anj
Sep 7th, 2007, 01:21 PM
this code below will also call the popup window and it pass a value of empid which is the $_GET[empid]. Almost similar to what I need, but the different is I have to type first in the textbox and when I click the button I can get the value of the said textbox and pass it to the popup window..

<input type=\"button\" name=\"add\" value=\"Add contact\" onclick= \"return popitup('addcontact.php?empid=$_GET[empid]')\">

Kor
Sep 7th, 2007, 01:26 PM
...pass it to the popup window where? Where on that popupwindow?

che_anj
Sep 7th, 2007, 02:11 PM
<?php echo "<input type='button' name='ser' value='Search' onclick= \"return popitup('jobpicker.php?empid="$_POST[compname] "')\">";?>

ok.. it must be pass to the child window ('jobpicker.php')

Kor
Sep 7th, 2007, 03:37 PM
Sir, maybe my English is not understandable for you. I'll try to detail my question. OK, you want to pass a value to a popup window. OK, now, in fact the window object is the root of the elements, including the document object, thus in fact you can not put a value to the window (or document), you have to put it as a value somewhere inside the document (for instance in an input text as its value, or as clean text somewhere in the document....)

In other words. What do you intend to do with the passed value afterwards?

che_anj
Sep 7th, 2007, 03:47 PM
Im Ms.

anyways, i will share you a code, Almost there. but I dont know where to put the post_value(); which holds the value of the textbox and ready to pass to the child window.


<script language="javascript">
function popitup(url)
{
newwindow=window.open(url,'name','height=200,width=670, left=250, top=200');
if (window.focus) {newwindow.focus()}
return false;
}
function post_value(){
opener.document.frm.c_name.value = document.f1.p_name.value;
self.close();
}
</script>

<form method="post" action='' name="f1">

Company Name:<input type=text name='p_name'> <br>
<input type="button" onclick="popitup('child.html');">
</form>

document.frm.c_name.value // this will catch the value from parent window
document.f1.p_name.value; // value from parent to window

After I got the value from parent window, I will be executing a query code.

example... in the child window..

If the value was being pass by parent to child is "FRS"..

so.. $query="select * from table where empname='inputboxvalue'";

Kor
Sep 7th, 2007, 03:59 PM
ok, look, here's a code to create a global variable (I will call it "newvariable") which will belong to the popup window, and give it that value from the parent's textbox. Later you may do whichever with it, as you didn't succede in telling me what you want to do with that passed value
try this


function popitup(url)
{
newwindow=window.open(url,'name','height=200,width=670, left=250, top=200');
if (window.focus) {newwindow.focus()}
newwindow['newvariable']=document.getElementsByName('compname')[0].value
return false;
}

che_anj
Sep 7th, 2007, 04:05 PM
How would the child window gets the value of compname?

che_anj
Sep 7th, 2007, 04:08 PM
Passing input value from Parent Window to Child Window,, thats what I mean ...

Kor
Sep 7th, 2007, 04:18 PM
For the last time... to pass the value where on the child window? As a global variable, to be used later? Or do you want to fill another text field existent in the child window? Or do you want to write some text in the body of the child window with that value. Or what?

Sir, am I enough clear?: WHAT you want to do with that value on the child popup window?

Or you want to pass it in the address bar of the child window, same as a query?

Make all these clear, please...

che_anj
Sep 7th, 2007, 04:28 PM
Or you want to pass it in the address bar of the child window, same as a query?


sorry if I made you confuse.. Yes Its actually my first choice to pass it in the address bar of child window..

Kor
Sep 7th, 2007, 04:37 PM
Why haven't you told me so from the beginning? :)


function popitup(url)
{
var val=document.getElementsByName('compname')[0].value;
newwindow=window.open(url+'?compname='+val,'name','height=200,width=670, left=250, top=200');
if (window.focus) {newwindow.focus()}
return false;
}

che_anj
Sep 7th, 2007, 04:46 PM
Oh Im so sorry..


It works now! Thanks a Lot Mr. Moderator.. ;)