473,217 Members | 2,042 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,217 software developers and data experts.

How to get a Dynamic Javacript Form variables seperated in PHP

Appreciate any help!!!

PROBLEM: I have this form that allows the user to dynamically create
additional fields (see javascript code bellow). I am trying to retrieve
the values entered into these fields from my php script. I ultimatly
need to pick out the variables and place the values into my php script
page. I have worked with a little code I found on php.net (see php code
below), but I wan unable to grasp the knowledge on how to seperate the
variables in the address bar. Please reply.

QUESTION: How do I create variables in my php script from my dynamic
javascript form?

PHP CODE:
foreach($_GET as $name => $value) {
print "$name : $value<br>";
}

JAVASCRIPT CODE:
<HEAD>
<!-- Begin
function createForm(number) {
data = "";
inter = "'";
if (number < 16 && number > -1) {
for (i=1; i <= number; i++) {
if (i < 10) spaces=" ";
else spaces=" ";
data = data + "URL " + i + " :" + spaces
+ "<input type='text' size=10 name=" + inter
+ "url" + i + inter + "'><br>";
}
if (document.layers) {
document.layers.cust.document.write(data);
document.layers.cust.document.close();
}
else {
if (document.all) {
cust.innerHTML = data;
}
}
}
else {
window.alert("Please select up to 15 entries.");
}
}
// End -->
</script>
</HEAD>
<BODY>
<center>
<form name=counter>
Number of URLs to enter:
<input type=text name=number size=5>
<input type=button value="Update"
onClick="createForm(counter.number.value);">
</form>
<br>
<form name="webform" action="get.php">
<input type=text size=20 name=name onChange="msg(this.form)">
<!-- Placeholder for dynamic form contents -->
<span id=cust style="position:relative;"></span>
<input type=submit value="Send">
</form>

Jul 17 '05 #1
11 2334
I noticed that Message-ID:
<11********************@z14g2000cwz.googlegroups.c om> from propizzy
contained the following:

well I'd do it all with PHP but...

data = data + "URL " + i + " :" + spaces
+ "<input type='text' size=10 name=" + inter
+ "url[]" + i + inter + "'><br>";

adding square brackets to the name of the text box means the urls will
be added to an array.

<form name="webform" action="get.php">

you need to change this to

<form name="webform" method="post" action="get.php">

Then you can do this

$urls=$_POST['url'];

foreach($urls as $key=>$value){
$key++;
echo "URL#$key: $value<br>\n";
}

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #2
Thanks for the reply Geoff,

I'm going to change my Javascript to PHP first, then I'll try it. I put
the brackets in the url and paste the code you supplied in my get.php
page and I got the following errors. I also changed the method to post.
Please check back later...

Notice: Undefined index: url in D:\My Webs\My Extreme Web\get.php on
line 11
Warning: Invalid argument supplied for foreach() in D:\My Webs\My
Extreme Web\get.php on line 14

~propizzy

Jul 17 '05 #3
Thanks for the reply Geoff,

I'm going to change my Javascript to PHP first, then I'll try it. I put
the brackets in the url and paste the code you supplied in my get.php
page and I got the following errors. I also changed the method to post.
Please check back later...

Notice: Undefined index: url in D:\My Webs\My Extreme Web\get.php on
line 11
Warning: Invalid argument supplied for foreach() in D:\My Webs\My
Extreme Web\get.php on line 14

~propizzy

Jul 17 '05 #4
never mind I messed up because I changed your $urls=$_POST['url']; to
$urls=$_GET['url'];... Now that I changed it back it works. Thanks for
the help

Jul 17 '05 #5
I noticed that Message-ID:
<11**********************@c13g2000cwb.googlegroups .com> from propizzy
contained the following:
never mind I messed up because I changed your $urls=$_POST['url']; to
$urls=$_GET['url'];... Now that I changed it back it works. Thanks for
the help


:-)
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #6
Geoff,

Maybe you can help me with this.

PROBLEM: Trying to take a couple foreach statements and control the
output. My dynamic form now has an additional input text box that
submits to the PHP CODE below. I need to take the values out of the 1st
input ("system") plus 2nd input ("ipaddress") and eliminate the values
in the middle (please see RESULTS below).

QUESTION: How can I control the output of these foreach statements to
ultimately eliminate the two middle results?

NOTE: Middle values are noted with an star *.

PHP CODE:
//create vlan <system> and <ipaddress>
foreach($system as $key=>$value1){
$key++;
foreach($ipaddress as $key2=>$value2){
$key2++;
echo "create system $value1 <br>\n";
echo "configure $value1 ipaddress $value2 <br>\n";
}
}

RESULTS:
create system system1
configure system1 ipaddress 10.10.10.2
*create system system1
*configure system1 ipaddress 10.10.10.3
*create system system2
*configure system2 ipaddress 10.10.10.2
create system system2
configure system2 ipaddress 10.10.10.3

Jul 17 '05 #7
I noticed that Message-ID:
<11**********************@o13g2000cwo.googlegroups .com> from propizzy
contained the following:
PHP CODE:
//create vlan <system> and <ipaddress>
foreach($system as $key=>$value1){
$key++;
foreach($ipaddress as $key2=>$value2){
$key2++;
echo "create system $value1 <br>\n";
echo "configure $value1 ipaddress $value2 <br>\n";
}
}


Well if I have this right you have an array of systems and a
corresponding array of ip addresses, each with the same number of
elements and each with sequential array keys?

If so...

for($i=0;$i<count($system);$i++){
echo "create system ".$system[$i]." <br>\n";
echo "configure ".$system[$i]." ipaddress ."$ipaddress[$i]." <br>\n";
}

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #8
that is tight!!!! (as they say here in California)... Thanks Dude!

Jul 17 '05 #9
I noticed that Message-ID:
<11**********************@o13g2000cwo.googlegroups .com> from propizzy
contained the following:
that is tight!!!! (as they say here in California)... Thanks Dude!


I hope it's a compliment, in the UK 'tight' either means drunk or
miserly. :-)

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #10
JDS
On Wed, 23 Feb 2005 19:20:36 +0000, Geoff Berrow wrote:
I hope it's a compliment, in the UK 'tight' either means drunk or
miserly. :-)


http://www.ocf.berkeley.edu/~wrader/slang/t.html

--
JDS | je*****@example.invalid
| http://www.newtnotes.com
DJMBS | http://newtnotes.com/doctor-jeff-master-brainsurgeon/

Jul 17 '05 #11
nice hook up jeff...

Jul 17 '05 #12

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

Similar topics

0
by: Pat Patterson | last post by:
I'm having serious issues with a page I'm developing. I just need some simple help, and was hoping someone might be able to help me out in here. I have a form, that consists of 3 pages of...
1
by: Nathan Bloomfield | last post by:
Does anyone know if there is any documentation which relates to Access2k + ? or can anyone help adjust the code? I am having trouble converting the DAO references. TITLE :INF: How to...
1
by: Will | last post by:
Hi all. I'm learning VB.Net and am developing a WinForms app. I'm trying to make an app that I will use to scan in one or more than on image. I want to use a tabbed interface to hold each image....
1
by: Jason Chan | last post by:
I have a paging datalist which show a list of thumbnail. Above the datalist there is a dropdown to jump to different paging. On Page_load, I bind the datalist according to the current page. On...
2
by: weiwei | last post by:
<% Option Explicit %> <!--#include file="includes/conn.inc"--> <% Dim rds, ID %> <% Set rds = Server.CreateObject("ADODB.Recordset") %> <% rds.Open "select RecID, LocationName from Location ORDER...
2
by: deejayquai | last post by:
Hi I'm trying to produce a report based on a dynamic crosstab. Ultimately i'd like the report to actually become a sub report within a student end of year record of achievement. The dynamic...
26
by: Jerim79 | last post by:
I need to create a form that takes a number that the user enters, and duplicates a question the number of times the user entered. For instance, if the customer enters 5 on the first page, when...
3
by: creative1 | last post by:
Here is how you create a complex data report that involves parent and child commands and you can update information at runtime. Its pretty straight forward to work with simple queries; however,...
14
ollyb303
by: ollyb303 | last post by:
Hi, I am trying to create a dynamic crosstab report which will display number of calls handled (I work for a call centre) per day grouped by supervisor. I have one crosstab query (Query1) which...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.