473,799 Members | 3,061 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to retrieve javascript object value in PHP ?

I want to set an initial text in a TEXTAREA based on the value selected
in an earlier SELECT box in the same document.

I tried something like

$init_text=set_ init_text() ;
<TEXTAREA>
<?php echo $init_text ; ?>
</TEXTAREA>

function set_init_text() {
return <script>
document.forms[0].SelectBox.opti ons[document.forms[0].SelectBox.sele ctedIndex].value
</script }
But I get a php syntax error with the <script> tag.

What's the correct way to do it ?

Jan 9 '06 #1
3 1947
Following on from 's message. . .
I want to set an initial text in a TEXTAREA based on the value selected
in an earlier SELECT box in the same document. Sorry but you have completely mis-understood how php works.

Client browser - "Web server! send me this resource"
Web server - "OK" [ FX rummages around while running AND FINISHING a php
script] "Here it is now - Thank you and have a nice day"
Client browser - "User I will show you the HTML just sent to me by the
server"
Javascript = client side
php = server side. [ie no interaction]


I tried something like

$init_text=set _init_text() ;
<TEXTAREA>
<?php echo $init_text ; ?>
</TEXTAREA>

function set_init_text() {
return <script>
document.for ms[0].SelectBox.opti ons[document.forms[0].SelectBox.sele ctedInde
x].value
</script }
But I get a php syntax error with the <script> tag.

What's the correct way to do it ?


--
PETER FOX Not the same since the pancake business flopped
pe******@eminen t.demon.co.uk.n ot.this.bit.no. html
2 Tees Close, Witham, Essex.
Gravity beer in Essex <http://www.eminent.dem on.co.uk>
Jan 9 '06 #2
On Mon, 09 Jan 2006 09:32:42 +0000, Peter Fox wrote:

No interaction, but php can quite happily write js just as easily as it
can write html/xhtml/xml/...
Following on from 's message. . .
I want to set an initial text in a TEXTAREA based on the value selected
in an earlier SELECT box in the same document.

Sorry but you have completely mis-understood how php works.

Client browser - "Web server! send me this resource" Web server - "OK"
[ FX rummages around while running AND FINISHING a php script] "Here it
is now - Thank you and have a nice day" Client browser - "User I will
show you the HTML just sent to me by the server"
Javascript = client side
php = server side. [ie no interaction]


I tried something like

$init_text=se t_init_text() ;
<TEXTAREA>
<?php echo $init_text ; ?>
</TEXTAREA>

function set_init_text() {
return <script>
document.form s[0].SelectBox.opti ons[document.forms[0].SelectBox.sele ctedInde
x].value
</script }
But I get a php syntax error with the <script> tag.

What's the correct way to do it ?


Jan 9 '06 #3
Ike
Do an HTTP POST (or GET) of a form, where you send the object from
Javascript, calling the same page to rerender. When the page loads, in php,
check if the value was sent. Suppose I have a js variable 'x'. I then put it
in a hidden text field say, on a form, and POST the form.

When the page reloads, it tests to see if x has been "set" in javascript
(i.e. POSTED):

$x = $_POST['x'];

if $x =="" then it is the first time the form was loaded and x has not been
set in js. (or, a subsequent time for loading the form after a POST and x
was never set in js). You may want to check too if x==null, not sure if it
is null or "". -Ike
Jan 9 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4130
by: Eugfene | last post by:
I have the following function in a html file: function selectEdit(fileID, processCode, processID, fileName,fileDesc) { document.forms.recordID.value = fileID; document.forms.processor.value = processCode; ` document.forms.processorID.value = processID; document.forms.interfaceFileName.value = fileName; document.forms.fileNameDesc.value=fileDesc; document.forms.submit();
2
12571
by: Cheryl | last post by:
Hi, I have encounter a problem.Language use is C#. I would like to open a new window (is a modal window, where I m not able to switch from parent window after this window is open)from the parent window , where there are 3 dropdownlists and a "OK" button. Upon clicking the button, this window will close and the select of the dropdownlists will be collect and send back to the parent window. But I am do not know how to do it. Can...
5
2443
by: ggk517 | last post by:
We are trying to develop an Engineering application using PHP, Javascript with Informix as the back-end. Is it possible to retrieve data using Javascript but by accessing the Database. Say somebody enters part_no, than using Javascript is it possible to connect to the part master and retrieve the division and desc information? I am not allowed to use the PHP because this will require the user to insert the part number on the first...
11
1936
by: Patricio | last post by:
Hello all I open a PopUp that receives two variables (values). This PopUp must return a value as well. How can I retrieve this value? Thanks a lot.
2
1567
by: tomromanul | last post by:
Hi all, I built a Windows Froms user control and I use it in IE 6+. It functions properly (it displays properly in IE and executes code, such as displaying a message box), except that in the web page I cannot do any scripting (javascript) against it. This control has a public property Text2, which is initialized properly: <object id="simpleControl1" classid="http:WinControlCS.dll#WinControlCS.WinControl" height="300" width="300"...
6
3871
by: ashok.dhananjeyan | last post by:
Hi, Actually , I wrote one javascript to retrieve the name of the form in one particular page. what i did in this page is, <script> function checkbutton() {
1
1563
by: yootaeho | last post by:
Hi, I have the following script <%@LANGUAGE=Javascript%> <% var myClass = new LoginInfo(); myClass.sessionID = "1321312131"; Response.Cookies("testingCookies") = myClass; var recievedCookies = new LoginInfo();
4
2546
by: divina11 | last post by:
I'm trying to retrieve the options below, depending on the one the user selects, I'm bulliding a Calculator Program where user inputs 2 values via input box and then selects an operation: Code: (Javascript) <select id="mySelect"> <option>+</option> <option>-</option> <option>*</option> <option>/</option> </select>
21
2906
by: giandeo | last post by:
Hello Experts. Is it possible to retrieve the value from a populated pull down menu from a database and then use that value to access the same database to get the related fields. Example: Database name: sp Table: importer Field names: imp_code, imp_name, imp_address, imp_tel
2
5925
by: phpachu | last post by:
Hi, I hav created a group of textboxes using a loop and its names are unique and names are assigned using variable ( like <input type=text name=$name1>). Then How can i retrieve the values in that textboxes after a button click with in a loop. Really I cant move from here. Can anyone plz help me.. Part of the my code is given below <html> <table> <?php // i hav an array "assocArray" and its count is "countarray" for($i = 1; $i <...
0
10475
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10250
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10222
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7564
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6805
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4139
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3757
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2938
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.