473,385 Members | 1,645 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

how do you assign php to a row value in javascript

3
How can I make the tempInput.value set to the php echo statement. I am storing each value in a session, but when I do it this way or using setAttribute(), it only places the php statement directly in the input box.

This is the code I am using:

Expand|Select|Wrap|Line Numbers
  1.  
  2. function HDonCallReport_addCallsRecieved()
  3. {
  4.      var tbody = document.getElementById('CallsReceived').getElementsByTagName("TBODY")[0];
  5.      var row = document.createElement("TR"); // create a new table row
  6.      var td = new Array(4); // counting the table we made there are 8 cells per table row
  7.      var tempSelect;
  8.      var tempInput;
  9.      var rownum = tbody.rows.length; // not +1 because we have a header row
  10.  
  11.      // Create Time select box
  12.      td[0] = document.createElement("TD"); // create a td element     
  13.      tempInput = document.createElement("INPUT"); // create an input
  14.      tempInput.name = "Time_" + rownum; // name the input
  15.      tempInput.id = "Time_" + rownum; // give an id to the input
  16.      tempInput.size = 20; // set the size of the input
  17.      tempInput.value="<?php echo htmlentities($_POST['Time_']); ?>";
  18.      tempInput.onblur = "validateTimePicker(this)";
  19.      td[0].appendChild(tempInput); // add the select box to the table cell
  20.  
  21.      // Create Location input
  22.      td[1] = document.createElement("TD"); // create a table cell
  23.      tempInput = document.createElement("INPUT"); // create an input
  24.      tempInput.name = "Location_" + rownum; // name the input
  25.      tempInput.id = "Location_" + rownum; // give an id to the input
  26.      tempInput.size = 30; // set the size of the input
  27.      td[1].appendChild(tempInput); // add the input to the table cell
  28.  
  29.      // Create Who Called input
  30.      td[2] = document.createElement("TD");
  31.      tempInput = document.createElement("INPUT");
  32.      tempInput.name = "WhoCalled_" + rownum;
  33.      tempInput.id = "WhoCalled_" + rownum;
  34.      tempInput.size = 30;
  35.      td[2].appendChild(tempInput);
  36.  
  37.      // Create Response input
  38.      td[3] = document.createElement("TD");
  39.      tempInput = document.createElement("textarea");
  40.      tempInput.name = "Response_" + rownum;
  41.      tempInput.id = "Response_" + rownum; 
  42.      tempInput.rows = 2;
  43.      tempInput.cols = 30;
  44.      td[3].appendChild(tempInput);
  45.  
  46.  
  47.      // Append each cell to the row we created row
  48.      for(i=0; i<4; i++)
  49.          row.appendChild(td[i]);
  50.      // Append row to table so that it appears on screen
  51.      tbody.appendChild(row);
  52.  
  53.      // Increment the number of Code rows
  54.      document.CallsReceived.CodeCount1.value = parseInt(document.witness.CodeCount1.value) + 1;
  55. }
  56.  
  57.  
and this is what I want

[HTML]
<td >
<input id="Time_1" name="Time_1" size="20" value="<?php echo htmlentities($_POST['Time_1']); ?>" onblur="validateTimePicker(this)" />
<img src="gif/timepicker.gif" align="top" onclick="selectTime(this,Time_1);" STYLE="cursor:hand" />
</td>
[/HTML]
Aug 13 '07 #1
3 3339
pbmods
5,821 Expert 4TB
Heya, RJ. Welcome (back) to TSDN!

Fixed an... embarrassing typo in your thread title ~_^

Is your Javascript stored in a separate file?

Try passing the value as a parameter to your HDonCallReport_addCallsRecieved() function:
Expand|Select|Wrap|Line Numbers
  1. <input ... onsomething="HDonCallReport_addCallsRecieved('<?php echo $_POST['Time_']; ?>');" />
  2.  
And then modify your HDonCallReport_addCallsRecieved() function:
Expand|Select|Wrap|Line Numbers
  1. function HDonCallReport_addCallsRecieved( newValue )
  2. {
  3.     .
  4.     .
  5.     .
  6.     tempInput.value = newValue;
  7.     .
  8.     .
  9.     .
  10. }
  11.  
Aug 13 '07 #2
RJ2001
3
Thanks for the corection maybe I should of done a spell check on the heading.

But I have already tried passing it the string, I even created the string within the external .js file with var and it still just posts the expression to the input field.
Aug 13 '07 #3
pbmods
5,821 Expert 4TB
Heya, RJ.

.js files are generally not parsed by PHP.

By passing the value as a parameter to the function, the goal is to set up the JavaScript so that we are using a variable in the main HTML page so that the PHP does get processed.
Aug 13 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Matt | last post by:
If I assign VBScript server side variable a to javascript variable x, it is fine. <% Dim a, b a = 10 %> var x = <%= a %>; alert(x); But if I do the other way around, then it has 500 error....
4
by: Terry | last post by:
I have a number of input boxes used to display totals based on selected items for each row in a table. There are more than a few rows that are identical, except for the form field name. I have...
16
by: sneill | last post by:
How is it possible to take the value of a variable (in this case, MODE_CREATE, MODE_UPDATE, etc) and use that as an object property name? In the following example I want 'oIcon' object to have...
1
by: google | last post by:
It would seem that when I assign an HTML entity to a form text input using "inline" javascript that it will display properly. But when trying to set it via a function call, the entity text shows...
8
by: Sergei | last post by:
Hi, I am displaying modal dialog and passing values from the main form to the modal dialog and back. It works fine but if I used the following syntax on Page_Load(just for testing) in VB to...
4
by: philin007 | last post by:
Hi , I have the following javascript codes: ****************************************** <script language="JavaScript"> <!-- .... ..... if (nextRow >5) {
1
by: harpreet1433 | last post by:
how to assign value to a hidden field of stuts form what i actually want to do that assign it through javascript document.all.fieldname=value works well under IE and Netscape but in...
5
by: howa | last post by:
Hi, Consider a simple example, e.g. var a = { 'a': 'b', 'c': 'd' }
5
by: lianping | last post by:
Hi, I have a problem to assign a value into text box, below will be my script. Before view my script, let me hv quick explain on what is my problem: I would like to assign Java script value...
2
by: rahullko05 | last post by:
i am stuck in the problem, where after user logs in successfuly, i take him to the login thanks page. now on that page i need to retain the login name. I am not sure how to this. i have written a...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.