FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » for each syntax
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
for each syntax [message #169597] Sat, 18 September 2010 20:02 Go to next message
GarryJones is currently offline  GarryJones
Messages: 21
Registered: September 2010
Karma: 0
Junior Member
I need to automatically write a few lines of code with php.

This is the output i need
if ($_POST['resmalval109'] == 109) {
$resmalval=109;
} elseif ($_POST['resmalval110'] == 110) {
$resmalval=110;
} elseif ($_POST['resmalval111'] == 111) {
$resmalval=111;
} elseif ($_POST['resmalval112'] == 112) {
$resmalval=112;
} elseif ($_POST['resmalval113'] == 113) {
$resmalval=113;
} elseif ($_POST['resmalval114'] == 114) {
$resmalval=114;
} elseif ($_POST['resmalval115'] == 115) {
$resmalval=115;
} else {
// something else
}

The required numbers just happen to be sequential at the moment, but
over time these values will change, Instead of manually writing the
above code every time I want to create it with php.

I have the required numbers in an array.
$arr_single = array(109,110,111,112,113,114,115);

So my guess is using "for each" I can write in each number where it is
needed until the array is empty. I can't use the $var++ trick as these
numbers can (for example) change to

$arr_single = array(109,111,112,113,115);

Any help in right direction greatly appreciated.,,
Re: for each syntax [message #169602 is a reply to message #169597] Sat, 18 September 2010 20:19 Go to previous messageGo to next message
Luuk is currently offline  Luuk
Messages: 329
Registered: September 2010
Karma: 0
Senior Member
On 18-09-10 22:02, GarryJones wrote:
> I need to automatically write a few lines of code with php.
>
> This is the output i need
> if ($_POST['resmalval109'] == 109) {
> $resmalval=109;
> } elseif ($_POST['resmalval110'] == 110) {
> $resmalval=110;
> } elseif ($_POST['resmalval111'] == 111) {
> $resmalval=111;
> } elseif ($_POST['resmalval112'] == 112) {
> $resmalval=112;
> } elseif ($_POST['resmalval113'] == 113) {
> $resmalval=113;
> } elseif ($_POST['resmalval114'] == 114) {
> $resmalval=114;
> } elseif ($_POST['resmalval115'] == 115) {
> $resmalval=115;
> } else {
> // something else
> }
>
> The required numbers just happen to be sequential at the moment, but
> over time these values will change, Instead of manually writing the
> above code every time I want to create it with php.
>
> I have the required numbers in an array.
> $arr_single = array(109,110,111,112,113,114,115);
>
> So my guess is using "for each" I can write in each number where it is
> needed until the array is empty. I can't use the $var++ trick as these
> numbers can (for example) change to
>
> $arr_single = array(109,111,112,113,115);
>
> Any help in right direction greatly appreciated.,,
>

<?php

$arr_single = array(109,110,111,112,113,114,115);

for ($x=0; $x<sizeof($arr_single); $x++) {
echo "x:$x e:".$arr_single[$x]."<br>";
}

?>


--
Luuk
Re: for each syntax [message #169604 is a reply to message #169597] Sat, 18 September 2010 20:21 Go to previous messageGo to next message
spambait is currently offline  spambait
Messages: 35
Registered: September 2010
Karma: 0
Member
In article <6a86e2b1-a632-4415-9d1b-608bf205ffd9(at)k30g2000vbn(dot)googlegroups(dot)com>, GarryJones <morack(at)algonet(dot)se> wrote:
> I need to automatically write a few lines of code with php.
>
> This is the output i need
> if ($_POST['resmalval109'] == 109) {
> $resmalval=109;
> } elseif ($_POST['resmalval110'] == 110) {
> $resmalval=110;
> } elseif ($_POST['resmalval111'] == 111) {
> $resmalval=111;
> } elseif ($_POST['resmalval112'] == 112) {
> $resmalval=112;
> } elseif ($_POST['resmalval113'] == 113) {
> $resmalval=113;
> } elseif ($_POST['resmalval114'] == 114) {
> $resmalval=114;
> } elseif ($_POST['resmalval115'] == 115) {
> $resmalval=115;
> } else {
> // something else
> }
>
> The required numbers just happen to be sequential at the moment, but
> over time these values will change, Instead of manually writing the
> above code every time I want to create it with php.
>
> I have the required numbers in an array.
> $arr_single = array(109,110,111,112,113,114,115);
>
> So my guess is using "for each" I can write in each number where it is
> needed until the array is empty. I can't use the $var++ trick as these
> numbers can (for example) change to
>
> $arr_single = array(109,111,112,113,115);
>
> Any help in right direction greatly appreciated.,,
>
Perhaps if you'd describe what it is you're actually trying to -- not the
method you've chosen to try to do it -- we could be of more help. Please give
a general description of the task. There may be other, much simpler, methods
of getting it done.
Re: for each syntax [message #169605 is a reply to message #169597] Sat, 18 September 2010 20:28 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 9/18/2010 4:02 PM, GarryJones wrote:
> I need to automatically write a few lines of code with php.
>
> This is the output i need
> if ($_POST['resmalval109'] == 109) {
> $resmalval=109;
> } elseif ($_POST['resmalval110'] == 110) {
> $resmalval=110;
> } elseif ($_POST['resmalval111'] == 111) {
> $resmalval=111;
> } elseif ($_POST['resmalval112'] == 112) {
> $resmalval=112;
> } elseif ($_POST['resmalval113'] == 113) {
> $resmalval=113;
> } elseif ($_POST['resmalval114'] == 114) {
> $resmalval=114;
> } elseif ($_POST['resmalval115'] == 115) {
> $resmalval=115;
> } else {
> // something else
> }
>
> The required numbers just happen to be sequential at the moment, but
> over time these values will change, Instead of manually writing the
> above code every time I want to create it with php.
>
> I have the required numbers in an array.
> $arr_single = array(109,110,111,112,113,114,115);
>
> So my guess is using "for each" I can write in each number where it is
> needed until the array is empty. I can't use the $var++ trick as these
> numbers can (for example) change to
>
> $arr_single = array(109,111,112,113,115);
>
> Any help in right direction greatly appreciated.,,
>

I agree with Doug. Any time I see something like this, I know someone
is trying to force something which is easy.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: for each syntax [message #169608 is a reply to message #169597] Sat, 18 September 2010 21:33 Go to previous messageGo to next message
Michael Fesser is currently offline  Michael Fesser
Messages: 215
Registered: September 2010
Karma: 0
Senior Member
.oO(GarryJones)

> I need to automatically write a few lines of code with php.
>
> This is the output i need
> if ($_POST['resmalval109'] == 109) {
> $resmalval=109;
> } elseif ($_POST['resmalval110'] == 110) {
> $resmalval=110;
> } elseif ($_POST['resmalval111'] == 111) {
> $resmalval=111;
> } elseif ($_POST['resmalval112'] == 112) {
> $resmalval=112;
> } elseif ($_POST['resmalval113'] == 113) {
> $resmalval=113;
> } elseif ($_POST['resmalval114'] == 114) {
> $resmalval=114;
> } elseif ($_POST['resmalval115'] == 115) {
> $resmalval=115;
> } else {
> // something else
> }
>
> The required numbers just happen to be sequential at the moment, but
> over time these values will change, Instead of manually writing the
> above code every time I want to create it with php.

Why all the if-elses? If you already know what you're looking for, you
can easily use PHP's array functions to reduce this code to 2 or 3
lines. And it would always be the same, whether you have 5 numbers to
check or 500.

But I also agree with the others that there's at least something strange
about the above. I would even say it looks completely wrong by design.
So please post some more details.

Micha
Re: for each syntax [message #169610 is a reply to message #169605] Sat, 18 September 2010 23:17 Go to previous messageGo to next message
spambait is currently offline  spambait
Messages: 35
Registered: September 2010
Karma: 0
Member
In article <i737cr$a2i$1(at)news(dot)eternal-september(dot)org>, Jerry Stuckle <jstucklex(at)attglobal(dot)net> wrote:
> On 9/18/2010 4:02 PM, GarryJones wrote:
>> I need to automatically write a few lines of code with php.
>>
>> This is the output i need
>> if ($_POST['resmalval109'] == 109) {
>> $resmalval=109;
>> } elseif ($_POST['resmalval110'] == 110) {
>> $resmalval=110;
>> } elseif ($_POST['resmalval111'] == 111) {
>> $resmalval=111;
>> } elseif ($_POST['resmalval112'] == 112) {
>> $resmalval=112;
>> } elseif ($_POST['resmalval113'] == 113) {
>> $resmalval=113;
>> } elseif ($_POST['resmalval114'] == 114) {
>> $resmalval=114;
>> } elseif ($_POST['resmalval115'] == 115) {
>> $resmalval=115;
>> } else {
>> // something else
>> }
>>
>> The required numbers just happen to be sequential at the moment, but
>> over time these values will change, Instead of manually writing the
>> above code every time I want to create it with php.
>>
>> I have the required numbers in an array.
>> $arr_single = array(109,110,111,112,113,114,115);
>>
>> So my guess is using "for each" I can write in each number where it is
>> needed until the array is empty. I can't use the $var++ trick as these
>> numbers can (for example) change to
>>
>> $arr_single = array(109,111,112,113,115);
>>
>> Any help in right direction greatly appreciated.,,
>>
>
> I agree with Doug. Any time I see something like this, I know someone
> is trying to force something which is easy.
>
I don't see it quite that way, Jerry -- more that he's latched on to one
particular method of solving a problem, and is determined to solve the problem
using that method no matter what. Sometimes one needs to step back and think
"What am I really trying to accomplish here?". Without doing so, it's not
possible to consider alternative methods of solving the problem.
Re: for each syntax [message #169611 is a reply to message #169610] Sat, 18 September 2010 23:55 Go to previous messageGo to next message
GarryJones is currently offline  GarryJones
Messages: 21
Registered: September 2010
Karma: 0
Junior Member
On Sep 19, 1:17 am, spamb...@milmac.com (Doug Miller) wrote:
> Sometimes one needs to step back and think
> "What am I really trying to accomplish here?". Without doing so, it's not
> possible to consider alternative methods of solving the problem.

I have a booking site where users can click on a trip.

On the booking choice page there is a <tr><td> for each trip with a
description pulled in from info on a mysql server dynamicaly
To create the correct <tr><td>'s all I have to do is to add or remove
an id number from the array. If the number is there it will create the
<td> with the correct info.

ie if the array is 111,112,113,114 then four <tr><td> are
I place an ok box at the end of each <tr>

To do this I make each <tr><td> its own unique form.
Each ok box submits the form.
To cut a corner I make each ok box redirect to the same page.

The example code for 1 of these <tr> is

<tr>
<td width="650" valign="top" class="resmallefty">Chase The
Sun<br>2010-10-02 -> 2010-10-12<br>9 400:-</td>
<td width="150" valign="middle" class="barstyle">
<FORM action="boksteg2.php" method="post" name="steg1109"
id="steg1109" ><input name="resmalval109" type="hidden" value="109">
<input type="Submit" value = "Boka NU">
</FORM>
</td>
</tr>

Every <tr> has a form with a unique name.

To create the above code I use this code for each value in the array
(varid can be 109,110,111, etc as explained above
---------------------------------------------------------------------
<?
print '<tr><td >' . $var1 . '<br>';
print $var2 . " -> " . $var3 . "<br>" . $var3 . ":-";
echo '</td>';
?>

<td>
<FORM action="boksteg2.php" method="post" name="steg1<?= $varid ?>"
id="steg1<?= $varid?>" ><input name="resmalval<?= $varid?>"
type="hidden" value="<?= $varid?>">
<input type="Submit" value = "Boka NU">
</FORM>
</td>
</tr>
----------------------------------------------------------------------

As you can see the name of the form I am sending to is identical for
all OK buttons

On that page I need to set a value according to which ok button the
user clicked on.

if ($_POST['resmalval109'] == 109) {
$resmalval=109;
} elseif ($_POST['resmalval110'] == 110) {
$resmalval=110;
etc until all value found

So if the user has clicked on the ok button for the form with the
input name "resmalval109" the value I need to read in is 109

if ($_POST['resmalval109'] == 109) {

Gives yes, the input name resmalval109 is set to 109 because 109 is
read in by the post. It then does not need to check for 110, 111 etc,
it bypasses the rest of the if and I can now use my value to do what I
need to do.

When these id values change it would be nice if I don't have to edit
the long-winded code, so I thought I could use "for each" and write
the else /elseifs for each value in the array

I may well be going about this the wrong way, but dont have more
knowledge than that I pocess today.


So any help appreciated

Garry Jones
Sweden
Re: for each syntax [message #169612 is a reply to message #169610] Sun, 19 September 2010 00:33 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 9/18/2010 7:17 PM, Doug Miller wrote:
> In article<i737cr$a2i$1(at)news(dot)eternal-september(dot)org>, Jerry Stuckle<jstucklex(at)attglobal(dot)net> wrote:
>> On 9/18/2010 4:02 PM, GarryJones wrote:
>>> I need to automatically write a few lines of code with php.
>>>
>>> This is the output i need
>>> if ($_POST['resmalval109'] == 109) {
>>> $resmalval=109;
>>> } elseif ($_POST['resmalval110'] == 110) {
>>> $resmalval=110;
>>> } elseif ($_POST['resmalval111'] == 111) {
>>> $resmalval=111;
>>> } elseif ($_POST['resmalval112'] == 112) {
>>> $resmalval=112;
>>> } elseif ($_POST['resmalval113'] == 113) {
>>> $resmalval=113;
>>> } elseif ($_POST['resmalval114'] == 114) {
>>> $resmalval=114;
>>> } elseif ($_POST['resmalval115'] == 115) {
>>> $resmalval=115;
>>> } else {
>>> // something else
>>> }
>>>
>>> The required numbers just happen to be sequential at the moment, but
>>> over time these values will change, Instead of manually writing the
>>> above code every time I want to create it with php.
>>>
>>> I have the required numbers in an array.
>>> $arr_single = array(109,110,111,112,113,114,115);
>>>
>>> So my guess is using "for each" I can write in each number where it is
>>> needed until the array is empty. I can't use the $var++ trick as these
>>> numbers can (for example) change to
>>>
>>> $arr_single = array(109,111,112,113,115);
>>>
>>> Any help in right direction greatly appreciated.,,
>>>
>>
>> I agree with Doug. Any time I see something like this, I know someone
>> is trying to force something which is easy.
>>
> I don't see it quite that way, Jerry -- more that he's latched on to one
> particular method of solving a problem, and is determined to solve the problem
> using that method no matter what. Sometimes one needs to step back and think
> "What am I really trying to accomplish here?". Without doing so, it's not
> possible to consider alternative methods of solving the problem.

Which is the same as what I was saying - just different words.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: for each syntax [message #169613 is a reply to message #169611] Sun, 19 September 2010 00:35 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 9/18/2010 7:55 PM, GarryJones wrote:
> On Sep 19, 1:17 am, spamb...@milmac.com (Doug Miller) wrote:
>> Sometimes one needs to step back and think
>> "What am I really trying to accomplish here?". Without doing so, it's not
>> possible to consider alternative methods of solving the problem.
>
> I have a booking site where users can click on a trip.
>
> On the booking choice page there is a<tr><td> for each trip with a
> description pulled in from info on a mysql server dynamicaly
> To create the correct<tr><td>'s all I have to do is to add or remove
> an id number from the array. If the number is there it will create the
> <td> with the correct info.
>
> ie if the array is 111,112,113,114 then four<tr><td> are
> I place an ok box at the end of each<tr>
>
> To do this I make each<tr><td> its own unique form.
> Each ok box submits the form.
> To cut a corner I make each ok box redirect to the same page.
>
> The example code for 1 of these<tr> is
>
> <tr>
> <td width="650" valign="top" class="resmallefty">Chase The
> Sun<br>2010-10-02 -> 2010-10-12<br>9 400:-</td>
> <td width="150" valign="middle" class="barstyle">
> <FORM action="boksteg2.php" method="post" name="steg1109"
> id="steg1109"><input name="resmalval109" type="hidden" value="109">
> <input type="Submit" value = "Boka NU">
> </FORM>
> </td>
> </tr>
>
> Every<tr> has a form with a unique name.
>
> To create the above code I use this code for each value in the array
> (varid can be 109,110,111, etc as explained above
> ---------------------------------------------------------------------
> <?
> print '<tr><td>' . $var1 .'<br>';
> print $var2 . " -> " . $var3 ."<br>" . $var3 . ":-";
> echo '</td>';
> ?>
>
> <td>
> <FORM action="boksteg2.php" method="post" name="steg1<?= $varid ?>"
> id="steg1<?= $varid?>"><input name="resmalval<?= $varid?>"
> type="hidden" value="<?= $varid?>">
> <input type="Submit" value = "Boka NU">
> </FORM>
> </td>
> </tr>
> ----------------------------------------------------------------------
>
> As you can see the name of the form I am sending to is identical for
> all OK buttons
>
> On that page I need to set a value according to which ok button the
> user clicked on.
>
> if ($_POST['resmalval109'] == 109) {
> $resmalval=109;
> } elseif ($_POST['resmalval110'] == 110) {
> $resmalval=110;
> etc until all value found
>
> So if the user has clicked on the ok button for the form with the
> input name "resmalval109" the value I need to read in is 109
>
> if ($_POST['resmalval109'] == 109) {
>
> Gives yes, the input name resmalval109 is set to 109 because 109 is
> read in by the post. It then does not need to check for 110, 111 etc,
> it bypasses the rest of the if and I can now use my value to do what I
> need to do.
>
> When these id values change it would be nice if I don't have to edit
> the long-winded code, so I thought I could use "for each" and write
> the else /elseifs for each value in the array
>
> I may well be going about this the wrong way, but dont have more
> knowledge than that I pocess today.
>
>
> So any help appreciated
>
> Garry Jones
> Sweden

Why are you using different id's for values in every form? The browser
will only submit one form at a time.

I suggest you start with alt.html and get an understanding on how HTML
works. Your PHP will then be much easier.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: for each syntax [message #169614 is a reply to message #169613] Sun, 19 September 2010 02:16 Go to previous messageGo to next message
GarryJones is currently offline  GarryJones
Messages: 21
Registered: September 2010
Karma: 0
Junior Member
> I suggest you start with alt.html and get an understanding on how HTML
> works.   Your PHP will then be much easier.

Well, I have been working with HTML since 1995. No I am not an expert.
I have been in computers since 1979 and I gained some fame for the
first logged question about the year 2000 problem (IBM Knowledge base
summer 1980). So I have a computer/logical intelligence and a good-
enough-to-get-things-working-knowledge on many things. In five years
of php and mysql I have NEVER lost a user entered record. This is with
about 1,5 million keyed in records a year on the seven sites I work
with. Most of work is free in my spare time volentry work for sports
organisations.

In this actual case I started with a drop down menu. But the users
found it difficult to understad why they could not click on the
<tr><td> to chose the trip they wanted. Ie one click rather than
opening and selecting from a dropdown menu and then clicking OK.

The <tr><td> are needed for details to explain trip itinery.

So I went with this (Example with 2 forms).

<tr><td>Trip 1 name and details</td>
<td width="150" valign="middle" class="barstyle">
<FORM action="boksteg2.php" method="post" name="steg110" id="steg110"
> <input name="resmalval111" type="hidden" value="110">
<input type="Submit" value = "Boka NU">
</FORM>
</td></tr>

<tr><td>Trip 2 name and details</td>
<td width="150" valign="middle" class="barstyle">
<FORM action="boksteg2.php" method="post" name="steg111" id="steg111"
> <input name="resmalval111" type="hidden" value="111">
<input type="Submit" value = "Boka NU">
</FORM>
</td></tr>

I only want one form Entered. I want it as a one-click operation.

If the first form is Submitted it sends 110 to the next page
If the second form is Submitted it sends 111 to the next page

Bascially I need is x number of submit buttons that send x number of
unique values to the next page. My method works.

Now when on the next page it needs to do something with the value it
received. My method necessitates a long-winded code that I thought I
could simplify by dynamicly creating it with php and "for each"

If you can point me to an easier way then ok, but I do have it working
now, even if I am not happy with the code.... as its long winded.
Re: for each syntax [message #169615 is a reply to message #169614] Sun, 19 September 2010 02:23 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 9/18/2010 10:16 PM, GarryJones wrote:
>> I suggest you start with alt.html and get an understanding on how HTML
>> works. Your PHP will then be much easier.
>
> Well, I have been working with HTML since 1995. No I am not an expert.
> I have been in computers since 1979 and I gained some fame for the
> first logged question about the year 2000 problem (IBM Knowledge base
> summer 1980). So I have a computer/logical intelligence and a good-
> enough-to-get-things-working-knowledge on many things. In five years
> of php and mysql I have NEVER lost a user entered record. This is with
> about 1,5 million keyed in records a year on the seven sites I work
> with. Most of work is free in my spare time volentry work for sports
> organisations.
>
> In this actual case I started with a drop down menu. But the users
> found it difficult to understad why they could not click on the
> <tr><td> to chose the trip they wanted. Ie one click rather than
> opening and selecting from a dropdown menu and then clicking OK.
>
> The<tr><td> are needed for details to explain trip itinery.
>
> So I went with this (Example with 2 forms).
>
> <tr><td>Trip 1 name and details</td>
> <td width="150" valign="middle" class="barstyle">
> <FORM action="boksteg2.php" method="post" name="steg110" id="steg110"
>> <input name="resmalval111" type="hidden" value="110">
> <input type="Submit" value = "Boka NU">
> </FORM>
> </td></tr>
>
> <tr><td>Trip 2 name and details</td>
> <td width="150" valign="middle" class="barstyle">
> <FORM action="boksteg2.php" method="post" name="steg111" id="steg111"
>> <input name="resmalval111" type="hidden" value="111">
> <input type="Submit" value = "Boka NU">
> </FORM>
> </td></tr>
>
> I only want one form Entered. I want it as a one-click operation.
>
> If the first form is Submitted it sends 110 to the next page
> If the second form is Submitted it sends 111 to the next page
>
> Bascially I need is x number of submit buttons that send x number of
> unique values to the next page. My method works.
>
> Now when on the next page it needs to do something with the value it
> received. My method necessitates a long-winded code that I thought I
> could simplify by dynamicly creating it with php and "for each"
>
> If you can point me to an easier way then ok, but I do have it working
> now, even if I am not happy with the code.... as its long winded.
>

Just because you've been working on it since 1995 doesn't mean you
understand it. And your attempts to show that prove you don't.

As I said - what is it you're TRYING TO DO - not HOW YOU'RE DOING IT?

And start with alt.html to get your html right. The rest will follow
easily.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: for each syntax [message #169616 is a reply to message #169614] Sun, 19 September 2010 02:52 Go to previous messageGo to next message
Michael Fesser is currently offline  Michael Fesser
Messages: 215
Registered: September 2010
Karma: 0
Senior Member
.oO(GarryJones)

> […]
> In this actual case I started with a drop down menu. But the users
> found it difficult to understad why they could not click on the
> <tr><td> to chose the trip they wanted. Ie one click rather than
> opening and selecting from a dropdown menu and then clicking OK.
>
> The <tr><td> are needed for details to explain trip itinery.
>
> So I went with this (Example with 2 forms).
>
> <tr><td>Trip 1 name and details</td>
> <td width="150" valign="middle" class="barstyle">
> <FORM action="boksteg2.php" method="post" name="steg110" id="steg110"
>> <input name="resmalval111" type="hidden" value="110">
> <input type="Submit" value = "Boka NU">
> </FORM>
> </td></tr>

BTW: Forms don't have names. You can remove it from the 'form' tag. You
can also remove the form IDs, unless you need them as targets for links.

> <tr><td>Trip 2 name and details</td>
> <td width="150" valign="middle" class="barstyle">
> <FORM action="boksteg2.php" method="post" name="steg111" id="steg111"
>> <input name="resmalval111" type="hidden" value="111">
> <input type="Submit" value = "Boka NU">
> </FORM>
> </td></tr>
>
> I only want one form Entered. I want it as a one-click operation.

Sure, but it doesn't explain the different names for your hidden fields.
Why not simply do it this way:

[…]
<input type="hidden" name="resmalval" value="110">
<input type="submit" value="Boka NU">
[…]
<input type="hidden" name="resmalval" value="111">
<input type="submit" value="Boka NU">
[…]

Same name for all hidden fields, but different values.

> If the first form is Submitted it sends 110 to the next page
> If the second form is Submitted it sends 111 to the next page
>
> Bascially I need is x number of submit buttons that send x number of
> unique values to the next page. My method works.

But it's more complicated than necessary.

Micha
Re: for each syntax [message #169617 is a reply to message #169616] Sun, 19 September 2010 03:00 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 9/18/2010 10:52 PM, Michael Fesser wrote:
> .oO(GarryJones)
>
>> […]
>> In this actual case I started with a drop down menu. But the users
>> found it difficult to understad why they could not click on the
>> <tr><td> to chose the trip they wanted. Ie one click rather than
>> opening and selecting from a dropdown menu and then clicking OK.
>>
>> The<tr><td> are needed for details to explain trip itinery.
>>
>> So I went with this (Example with 2 forms).
>>
>> <tr><td>Trip 1 name and details</td>
>> <td width="150" valign="middle" class="barstyle">
>> <FORM action="boksteg2.php" method="post" name="steg110" id="steg110"
>>> <input name="resmalval111" type="hidden" value="110">
>> <input type="Submit" value = "Boka NU">
>> </FORM>
>> </td></tr>
>
> BTW: Forms don't have names. You can remove it from the 'form' tag. You
> can also remove the form IDs, unless you need them as targets for links.
>
>> <tr><td>Trip 2 name and details</td>
>> <td width="150" valign="middle" class="barstyle">
>> <FORM action="boksteg2.php" method="post" name="steg111" id="steg111"
>>> <input name="resmalval111" type="hidden" value="111">
>> <input type="Submit" value = "Boka NU">
>> </FORM>
>> </td></tr>
>>
>> I only want one form Entered. I want it as a one-click operation.
>
> Sure, but it doesn't explain the different names for your hidden fields.
> Why not simply do it this way:
>
> […]
> <input type="hidden" name="resmalval" value="110">
> <input type="submit" value="Boka NU">
> […]
> <input type="hidden" name="resmalval" value="111">
> <input type="submit" value="Boka NU">
> […]
>
> Same name for all hidden fields, but different values.
>
>> If the first form is Submitted it sends 110 to the next page
>> If the second form is Submitted it sends 111 to the next page
>>
>> Bascially I need is x number of submit buttons that send x number of
>> unique values to the next page. My method works.
>
> But it's more complicated than necessary.
>
> Micha

Or even the appropriate value on the submit button itself...

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: for each syntax [message #169622 is a reply to message #169617] Sun, 19 September 2010 15:59 Go to previous messageGo to next message
GarryJones is currently offline  GarryJones
Messages: 21
Registered: September 2010
Karma: 0
Junior Member
On Sep 19, 5:00 am, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> On 9/18/2010 10:52 PM, Michael Fesser wrote:
>
>
>
>
>
>> .oO(GarryJones)
>
>>> […]
>>> In this actual case I started with a drop down menu. But the users
>>> found it difficult to understad why they could not click on the
>>> <tr><td>  to chose the trip they wanted. Ie one click rather than
>>> opening and selecting from a dropdown menu and then clicking OK.
>
>>> The<tr><td>  are needed for details to explain trip itinery.
>
>>> So I went with this (Example with 2 forms).
>
>>> <tr><td>Trip 1 name and details</td>
>>> <td width="150" valign="middle" class="barstyle">
>>> <FORM action="boksteg2.php" method="post" name="steg110" id="steg110"
>>>> <input name="resmalval111" type="hidden" value="110">
>>> <input type="Submit" value = "Boka NU">
>>> </FORM>
>>> </td></tr>
>
>> BTW: Forms don't have names. You can remove it from the 'form' tag. You
>> can also remove the form IDs, unless you need them as targets for links..
>
>>> <tr><td>Trip 2 name and details</td>
>>> <td width="150" valign="middle" class="barstyle">
>>> <FORM action="boksteg2.php" method="post" name="steg111" id="steg111"
>>>> <input name="resmalval111" type="hidden" value="111">
>>> <input type="Submit" value = "Boka NU">
>>> </FORM>
>>> </td></tr>
>
>>> I only want one form Entered. I want it as a one-click operation.
>
>> Sure, but it doesn't explain the different names for your hidden fields..
>> Why not simply do it this way:
>
>> […]
>> <input type="hidden" name="resmalval" value="110">
>> <input type="submit" value="Boka NU">
>> […]
>> <input type="hidden" name="resmalval" value="111">
>> <input type="submit" value="Boka NU">
>> […]
>
>> Same name for all hidden fields, but different values.
>
>>> If the first form is Submitted it sends 110 to the next page
>>> If the second form is Submitted it sends 111 to the next page
>
>>> Bascially I need is x number of submit buttons that send x number of
>>> unique values to the next page. My method works.
>
>> But it's more complicated than necessary.
>
>> Micha
>
> Or even the appropriate value on the submit button itself...
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck...@attglobal.net
> ==================- Hide quoted text -
>
> - Show quoted text -

Yep that did it, I just presumed I could not have the same form in the
html doc 5 times. I have only ever seen named forms and thought the
browser would refuse a form without a name. Now this code just go much
simpler and I am very happy for all of your patience and efforts..
Re: for each syntax [message #169623 is a reply to message #169622] Sun, 19 September 2010 18:01 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 9/19/2010 11:59 AM, GarryJones wrote:
> On Sep 19, 5:00 am, Jerry Stuckle<jstuck...@attglobal.net> wrote:
>> On 9/18/2010 10:52 PM, Michael Fesser wrote:
>>
>>
>>
>>
>>
>>> .oO(GarryJones)
>>
>>>> […]
>>>> In this actual case I started with a drop down menu. But the users
>>>> found it difficult to understad why they could not click on the
>>>> <tr><td> to chose the trip they wanted. Ie one click rather than
>>>> opening and selecting from a dropdown menu and then clicking OK.
>>
>>>> The<tr><td> are needed for details to explain trip itinery.
>>
>>>> So I went with this (Example with 2 forms).
>>
>>>> <tr><td>Trip 1 name and details</td>
>>>> <td width="150" valign="middle" class="barstyle">
>>>> <FORM action="boksteg2.php" method="post" name="steg110" id="steg110"
>>>> > <input name="resmalval111" type="hidden" value="110">
>>>> <input type="Submit" value = "Boka NU">
>>>> </FORM>
>>>> </td></tr>
>>
>>> BTW: Forms don't have names. You can remove it from the 'form' tag. You
>>> can also remove the form IDs, unless you need them as targets for links.
>>
>>>> <tr><td>Trip 2 name and details</td>
>>>> <td width="150" valign="middle" class="barstyle">
>>>> <FORM action="boksteg2.php" method="post" name="steg111" id="steg111"
>>>> > <input name="resmalval111" type="hidden" value="111">
>>>> <input type="Submit" value = "Boka NU">
>>>> </FORM>
>>>> </td></tr>
>>
>>>> I only want one form Entered. I want it as a one-click operation.
>>
>>> Sure, but it doesn't explain the different names for your hidden fields.
>>> Why not simply do it this way:
>>
>>> […]
>>> <input type="hidden" name="resmalval" value="110">
>>> <input type="submit" value="Boka NU">
>>> […]
>>> <input type="hidden" name="resmalval" value="111">
>>> <input type="submit" value="Boka NU">
>>> […]
>>
>>> Same name for all hidden fields, but different values.
>>
>>>> If the first form is Submitted it sends 110 to the next page
>>>> If the second form is Submitted it sends 111 to the next page
>>
>>>> Bascially I need is x number of submit buttons that send x number of
>>>> unique values to the next page. My method works.
>>
>>> But it's more complicated than necessary.
>>
>>> Micha
>>
>> Or even the appropriate value on the submit button itself...
>>
>>
>> - Show quoted text -
>
> Yep that did it, I just presumed I could not have the same form in the
> html doc 5 times. I have only ever seen named forms and thought the
> browser would refuse a form without a name. Now this code just go much
> simpler and I am very happy for all of your patience and efforts..

Still way too complicated. Go over to alt.html and find out how to
create your page *correctly*.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: for each syntax [message #169624 is a reply to message #169623] Sun, 19 September 2010 23:35 Go to previous messageGo to next message
Allodoxaphobia is currently offline  Allodoxaphobia
Messages: 21
Registered: September 2010
Karma: 0
Junior Member
>>> On 9/18/2010 10:52 PM, Michael Fesser wrote:
>
> Still way too complicated. Go over to alt.html and find out how to
> create your page *correctly*.

Don your asbestos underwear first...
Re: for each syntax [message #169629 is a reply to message #169616] Mon, 20 September 2010 09:49 Go to previous message
Erwin Moller is currently offline  Erwin Moller
Messages: 228
Registered: September 2010
Karma: 0
Senior Member
On 9/19/2010 4:52 AM, Michael Fesser wrote:
> .oO(GarryJones)
>

<snip>

>> <tr><td>Trip 1 name and details</td>
>> <td width="150" valign="middle" class="barstyle">
>> <FORM action="boksteg2.php" method="post" name="steg110" id="steg110"
>>> <input name="resmalval111" type="hidden" value="110">
>> <input type="Submit" value = "Boka NU">
>> </FORM>
>> </td></tr>
>
> BTW: Forms don't have names. You can remove it from the 'form' tag.

Forms can have names in HTML4 specification.
(But ID's are preferred.)

http://www.w3.org/TR/html401/interact/forms.html#h-17.3

name = cdata [CI]
This attribute names the element so that it may be referred to from
style sheets or scripts. Note. This attribute has been included for
backwards compatibility. Applications should use the id attribute to
identify elements.

(Appart from that I totally agree to your suggested approach.)

Regards,
Erwin Moller

--
"There are two ways of constructing a software design: One way is to
make it so simple that there are obviously no deficiencies, and the
other way is to make it so complicated that there are no obvious
deficiencies. The first method is far more difficult."
-- C.A.R. Hoare
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Stats comp.lang.php (last 7 days)
Next Topic: Illegal variable _files
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 10 14:45:04 GMT 2024

Total time taken to generate the page: 0.03323 seconds