Passing a parameter in PHP


A

amerar

Hi All,

I am writing some screen strictly in PHP. I have a screen with a
combo box in it. I do not want to use forms, just links on the page.

What I want to do, is when the user selects the value from the combo
box, and clicks on the link, I want the value in the combo box to be
passed as a parameter to another PHP page, and be used in that page.

I really want to avoid forms and the whole GET/POST stuff.

Is there any way to do this? Javascript maybe? I'm terrible at
Javascript, so if this is the way, if you could include and example,
I'd greatly appreciate it.

Thanks!
 
Ad

Advertisements

E

Erwin Moller

Hi All,

I am writing some screen strictly in PHP. I have a screen with a
combo box in it. I do not want to use forms, just links on the page.

What I want to do, is when the user selects the value from the combo
box, and clicks on the link, I want the value in the combo box to be
passed as a parameter to another PHP page, and be used in that page.

Well, you should rewrite all <a href=""> in your page on the fly if the
value in the box is changed.
Add the comboboxselection to the current URL.
But you said you suck at javascript, so this maight be over your head.
(read on)
I really want to avoid forms and the whole GET/POST stuff.

Is there any way to do this? Javascript maybe? I'm terrible at
Javascript, so if this is the way, if you could include and example,
I'd greatly appreciate it.

Maybe you could set a cookie when the combobox is changed that holds the
value of the element choosen.
You do not have to refresh the page or anything, just set a cookie.

Cookies are send to PHP on each request.
eg:

<?php
// cookie received for combobox?
if (isset($_COOKIE["mycombobox"])){
// do stuff with the value in $_COOKIE["mycombobox"]
}
?>

Maybe that helps.

Personally, if I see a combobox (or any formelement) without a
submitbutton, I will be confused.
Are you sure you want this?

Regards,
Erwin Moller
 
A

amerar

I am writing some screen strictly in PHP. I have a screen with a
combo box in it. I do not want to use forms, just links on the page.
What I want to do, is when the user selects the value from the combo
box, and clicks on the link, I want the value in the combo box to be
passed as a parameter to another PHP page, and be used in that page.

Well, you should rewrite all <a href=""> in your page on the fly if the
value in the box is changed.
Add the comboboxselection to the current URL.
But you said you suck at javascript, so this maight be over your head.
(read on)
I really want to avoid forms and the whole GET/POST stuff.
Is there any way to do this? Javascript maybe? I'm terrible at
Javascript, so if this is the way, if you could include and example,
I'd greatly appreciate it.

Maybe you could set a cookie when the combobox is changed that holds the
value of the element choosen.
You do not have to refresh the page or anything, just set a cookie.

Cookies are send to PHP on each request.
eg:

<?php
// cookie received for combobox?
if (isset($_COOKIE["mycombobox"])){
// do stuff with the value in $_COOKIE["mycombobox"]
}
?>

Maybe that helps.

Personally, if I see a combobox (or any formelement) without a
submitbutton, I will be confused.
Are you sure you want this?

Regards,
Erwin Moller



Well, the reason I do not want to use a form and submit and all is
because I am using styles to make the limk 'pretty' and such with
colors and all.......so, if I use a form, I have to use the boring
standard grey buttons.
 
A

amerar

Well, you should rewrite all <a href=""> in your page on the fly if the
value in the box is changed.
Add the comboboxselection to the current URL.
But you said you suck at javascript, so this maight be over your head.
(read on)
Maybe you could set a cookie when the combobox is changed that holds the
value of the element choosen.
You do not have to refresh the page or anything, just set a cookie.
Cookies are send to PHP on each request.
eg:
<?php
// cookie received for combobox?
if (isset($_COOKIE["mycombobox"])){
// do stuff with the value in $_COOKIE["mycombobox"]
}
?>
Maybe that helps.
Personally, if I see a combobox (or any formelement) without a
submitbutton, I will be confused.
Are you sure you want this?
Regards,
Erwin Moller

Well, the reason I do not want to use a form and submit and all is
because I am using styles to make the limk 'pretty' and such with
colors and all.......so, if I use a form, I have to use the boring
standard grey buttons.

And I might add, that there are several links on this page. Each
needing the value of the combo box. So, I was hoping I can use
something with the $_SESSION technique.....
 
E

Erwin Moller

(e-mail address removed) wrote:
Hi All,
I am writing some screen strictly in PHP. I have a screen with a
combo box in it. I do not want to use forms, just links on the page.
What I want to do, is when the user selects the value from the combo
box, and clicks on the link, I want the value in the combo box to be
passed as a parameter to another PHP page, and be used in that page.
Well, you should rewrite all <a href=""> in your page on the fly if the
value in the box is changed.
Add the comboboxselection to the current URL.
But you said you suck at javascript, so this maight be over your head.
(read on)
I really want to avoid forms and the whole GET/POST stuff.
Is there any way to do this? Javascript maybe? I'm terrible at
Javascript, so if this is the way, if you could include and example,
I'd greatly appreciate it.
Maybe you could set a cookie when the combobox is changed that holds the
value of the element choosen.
You do not have to refresh the page or anything, just set a cookie.
Cookies are send to PHP on each request.
eg:
<?php
// cookie received for combobox?
if (isset($_COOKIE["mycombobox"])){
// do stuff with the value in $_COOKIE["mycombobox"]
}
?>
Maybe that helps.
Personally, if I see a combobox (or any formelement) without a
submitbutton, I will be confused.
Are you sure you want this?
Regards,
Erwin Moller
Thanks!
Well, the reason I do not want to use a form and submit and all is
because I am using styles to make the limk 'pretty' and such with
colors and all.......so, if I use a form, I have to use the boring
standard grey buttons.

And I might add, that there are several links on this page. Each
needing the value of the combo box. So, I was hoping I can use
something with the $_SESSION technique.....

Yes, you could use an Ajaxoid approach to set the value of the combobox
into a session. It is easy.

But what happened with my cookie suggestion?
Don't you like cookies?

Erwin Moller
 
A

amerar

On Sep 4, 11:25 am, Erwin Moller
(e-mail address removed) wrote:
Hi All,
I am writing some screen strictly in PHP. I have a screen with a
combo box in it. I do not want to use forms, just links on the page.
What I want to do, is when the user selects the value from the combo
box, and clicks on the link, I want the value in the combo box to be
passed as a parameter to another PHP page, and be used in that page.
Well, you should rewrite all <a href=""> in your page on the fly if the
value in the box is changed.
Add the comboboxselection to the current URL.
But you said you suck at javascript, so this maight be over your head.
(read on)
I really want to avoid forms and the whole GET/POST stuff.
Is there any way to do this? Javascript maybe? I'm terrible at
Javascript, so if this is the way, if you could include and example,
I'd greatly appreciate it.
Maybe you could set a cookie when the combobox is changed that holds the
value of the element choosen.
You do not have to refresh the page or anything, just set a cookie.
Cookies are send to PHP on each request.
eg:
<?php
// cookie received for combobox?
if (isset($_COOKIE["mycombobox"])){
// do stuff with the value in $_COOKIE["mycombobox"]
}
?>
Maybe that helps.
Personally, if I see a combobox (or any formelement) without a
submitbutton, I will be confused.
Are you sure you want this?
Regards,
Erwin Moller
Thanks!
Well, the reason I do not want to use a form and submit and all is
because I am using styles to make the limk 'pretty' and such with
colors and all.......so, if I use a form, I have to use the boring
standard grey buttons.
And I might add, that there are several links on this page. Each
needing the value of the combo box. So, I was hoping I can use
something with the $_SESSION technique.....

Yes, you could use an Ajaxoid approach to set the value of the combobox
into a session. It is easy.

But what happened with my cookie suggestion?
Don't you like cookies?

Erwin Moller

I'm not really sure how that works. Is the cookie set when the user
clicks the link to go to the next page? How do I refer to the
variable(s) on the next page?
 
Ad

Advertisements

E

Erwin Moller

On Sep 4, 11:25 am, Erwin Moller
(e-mail address removed) wrote:
Hi All,
I am writing some screen strictly in PHP. I have a screen with a
combo box in it. I do not want to use forms, just links on the page.
What I want to do, is when the user selects the value from the combo
box, and clicks on the link, I want the value in the combo box to be
passed as a parameter to another PHP page, and be used in that page.
Well, you should rewrite all <a href=""> in your page on the fly if the
value in the box is changed.
Add the comboboxselection to the current URL.
But you said you suck at javascript, so this maight be over your head.
(read on)
I really want to avoid forms and the whole GET/POST stuff.
Is there any way to do this? Javascript maybe? I'm terrible at
Javascript, so if this is the way, if you could include and example,
I'd greatly appreciate it.
Maybe you could set a cookie when the combobox is changed that holds the
value of the element choosen.
You do not have to refresh the page or anything, just set a cookie.
Cookies are send to PHP on each request.
eg:
<?php
// cookie received for combobox?
if (isset($_COOKIE["mycombobox"])){
// do stuff with the value in $_COOKIE["mycombobox"]
}
?>
Maybe that helps.
Personally, if I see a combobox (or any formelement) without a
submitbutton, I will be confused.
Are you sure you want this?
Regards,
Erwin Moller
Thanks!
Well, the reason I do not want to use a form and submit and all is
because I am using styles to make the limk 'pretty' and such with
colors and all.......so, if I use a form, I have to use the boring
standard grey buttons.
And I might add, that there are several links on this page. Each
needing the value of the combo box. So, I was hoping I can use
something with the $_SESSION technique.....
Yes, you could use an Ajaxoid approach to set the value of the combobox
into a session. It is easy.

But what happened with my cookie suggestion?
Don't you like cookies?

Erwin Moller

Hi,

I'm not really sure how that works. Is the cookie set when the user
clicks the link to go to the next page?

No, you set the cookie immediately when the user changes the value of
the selectbox.
Use the onChange event handler on your combobox.
When it changes you use the selectedIndex property of the combobox to
find the current index, which in turn you can use to get the
corresponding value.

If you want to learn more, go to google and search for 'javascript
cookie tutorial', and you'll find sites like:

http://www.elated.com/articles/javascript-and-cookies/

and

http://www.echoecho.com/jscookies.htm

How do I refer to the
variable(s) on the next page?

Javascript can read the cookie value. Also on the next page.
Check the tutorials.

Regards,
Erwin Moller
 
T

The Natural Philosopher

Hi All,

I am writing some screen strictly in PHP. I have a screen with a
combo box in it. I do not want to use forms, just links on the page.

What I want to do, is when the user selects the value from the combo
box, and clicks on the link, I want the value in the combo box to be
passed as a parameter to another PHP page, and be used in that page.

I really want to avoid forms and the whole GET/POST stuff.
Why?

You only need declare a form, so that yu can send post and get variables
with the program.

You don't even need a submit button, you write minimal javascript the
uses onclick() to set up hidden variables and send the form back ..then
you pick the values in those up as post or get variables.

You don't even need a form, you can use the

<A HREF= "Mystuff.php?button5='clicked'">THIS IS BUTTON5</A>

and have mystuff.php do

$button5=$_GET['button5'];

if($button5=='clicked')
......etc;

Is there any way to do this? Javascript maybe? I'm terrible at
Javascript, so if this is the way, if you could include and example,
I'd greatly appreciate it.

Theres anoyther way with javascript that I found when trying to do it
last night..you can chain to a page and set POST variables as you go.

But it looked more complicated than the ones above, so I gave up on it.

Bascally I know of three ways to chain ino a ew windows when yu clck on
something.

The <a> method, the <SUBMIT> button, or an onclick() method inside the
element.

I only know of two easy ways to carry DATA to the program. One is by the
program name itself, and the other is post or get variables.

Get variables dont require a <form> to be declared, you can encapsulate
them in a URL. Post methods are more secure, but do. But thats ALL you
have to do to use them. Declare a form and some hidden variables to put
them in.

Then use a minimal amount of javascript to set them

e.g.
my.php
======


<?php
$myvar=$_POST['myvar'];
?>
<HTML>
<HEAD>
</HEAD>
<BODY>
<script type="text/javascript" language="JavaScript">
function do_myvar()
{
document.getelementsByName('myvar')[0].value="YES!";
document.forms[0].submit();
}
</script>
YOU got here<?if($myvar=='YES!')
print " by clicking CLICK HERE text!";
else print " on yer own!!";
?>
<BR>
<FORM method="POST" enctype="multipart/form-data" action="my.php">
<input type="hidden" name="myvar" value=" <?$myvar?>">
<span onclick="do_myvar()">Click HERE</span>
</FORM>
 
T

The Natural Philosopher

Hi All,
I am writing some screen strictly in PHP. I have a screen with a
combo box in it. I do not want to use forms, just links on the page.
What I want to do, is when the user selects the value from the combo
box, and clicks on the link, I want the value in the combo box to be
passed as a parameter to another PHP page, and be used in that page.
Well, you should rewrite all <a href=""> in your page on the fly if the
value in the box is changed.
Add the comboboxselection to the current URL.
But you said you suck at javascript, so this maight be over your head.
(read on)
I really want to avoid forms and the whole GET/POST stuff.
Is there any way to do this? Javascript maybe? I'm terrible at
Javascript, so if this is the way, if you could include and example,
I'd greatly appreciate it.
Maybe you could set a cookie when the combobox is changed that holds the
value of the element choosen.
You do not have to refresh the page or anything, just set a cookie.

Cookies are send to PHP on each request.
eg:

<?php
// cookie received for combobox?
if (isset($_COOKIE["mycombobox"])){
// do stuff with the value in $_COOKIE["mycombobox"]
}
?>

Maybe that helps.

Personally, if I see a combobox (or any formelement) without a
submitbutton, I will be confused.
Are you sure you want this?

Regards,
Erwin Moller



Well, the reason I do not want to use a form and submit and all is
because I am using styles to make the limk 'pretty' and such with
colors and all.......so, if I use a form, I have to use the boring
standard grey buttons.
NO YOU DON"T

see my example.

Create your own buttons with graphics, and encapsulate them with an
onclick..submit type slim javascript, or use URLs..

The FORM method is needed to allow submit() to pass stuff back, or at
least it's the easy way. You do NOT have to use the input elements tho.

I use mixture, TEXTAREA is hard to code otherwise, TEXTS look fine,
buttons look awful and are replaced, and FILE types are almost
impossible to style. although I did see a neat method posted up ..you
make them invisible and exactly superimpose a different element over the
top. you THINK you are clicking on that, but actually you are clicking
on a standard box underneath.
 
T

The Natural Philosopher

Erwin said:
On Sep 4, 11:25 am, Erwin Moller



(e-mail address removed) wrote:
Hi All,
I am writing some screen strictly in PHP. I have a screen with a
combo box in it. I do not want to use forms, just links on the page.
What I want to do, is when the user selects the value from the combo
box, and clicks on the link, I want the value in the combo box to be
passed as a parameter to another PHP page, and be used in that page.
Well, you should rewrite all <a href=""> in your page on the fly if the
value in the box is changed.
Add the comboboxselection to the current URL.
But you said you suck at javascript, so this maight be over your head.
(read on)
I really want to avoid forms and the whole GET/POST stuff.
Is there any way to do this? Javascript maybe? I'm terrible at
Javascript, so if this is the way, if you could include and example,
I'd greatly appreciate it.
Maybe you could set a cookie when the combobox is changed that holds
the
value of the element choosen.
You do not have to refresh the page or anything, just set a cookie.
Cookies are send to PHP on each request.
eg:
<?php
// cookie received for combobox?
if (isset($_COOKIE["mycombobox"])){
// do stuff with the value in $_COOKIE["mycombobox"]
}
?>
Maybe that helps.
Personally, if I see a combobox (or any formelement) without a
submitbutton, I will be confused.
Are you sure you want this?
Regards,
Erwin Moller
Thanks!
Well, the reason I do not want to use a form and submit and all is
because I am using styles to make the limk 'pretty' and such with
colors and all.......so, if I use a form, I have to use the boring
standard grey buttons.

And I might add, that there are several links on this page. Each
needing the value of the combo box. So, I was hoping I can use
something with the $_SESSION technique.....

Yes, you could use an Ajaxoid approach to set the value of the combobox
into a session. It is easy.

But what happened with my cookie suggestion?
Don't you like cookies?

Cookies make you fat.

Why is your name familiar? ISTR it from many years ago in a different
Usenet context entirely..
 
E

Erwin Moller

The said:
Erwin said:
On Sep 4, 11:25 am, Erwin Moller



(e-mail address removed) wrote:
Hi All,
I am writing some screen strictly in PHP. I have a screen with a
combo box in it. I do not want to use forms, just links on the page.
What I want to do, is when the user selects the value from the combo
box, and clicks on the link, I want the value in the combo box to be
passed as a parameter to another PHP page, and be used in that page.
Well, you should rewrite all <a href=""> in your page on the fly if
the
value in the box is changed.
Add the comboboxselection to the current URL.
But you said you suck at javascript, so this maight be over your head.
(read on)
I really want to avoid forms and the whole GET/POST stuff.
Is there any way to do this? Javascript maybe? I'm terrible at
Javascript, so if this is the way, if you could include and example,
I'd greatly appreciate it.
Maybe you could set a cookie when the combobox is changed that
holds the
value of the element choosen.
You do not have to refresh the page or anything, just set a cookie.
Cookies are send to PHP on each request.
eg:
<?php
// cookie received for combobox?
if (isset($_COOKIE["mycombobox"])){
// do stuff with the value in $_COOKIE["mycombobox"]
}
?>
Maybe that helps.
Personally, if I see a combobox (or any formelement) without a
submitbutton, I will be confused.
Are you sure you want this?
Regards,
Erwin Moller
Thanks!
Well, the reason I do not want to use a form and submit and all is
because I am using styles to make the limk 'pretty' and such with
colors and all.......so, if I use a form, I have to use the boring
standard grey buttons.

And I might add, that there are several links on this page. Each
needing the value of the combo box. So, I was hoping I can use
something with the $_SESSION technique.....

Yes, you could use an Ajaxoid approach to set the value of the
combobox into a session. It is easy.

But what happened with my cookie suggestion?
Don't you like cookies?

Cookies make you fat.

Yup.
I know that is a fact from firsthand experience. ;-)
Why is your name familiar? ISTR it from many years ago in a different
Usenet context entirely..

My name? Your name rings a bell too, but that could very well be because
you write in c.l.javascript or c.l.php.
I googled in groups with: "Erwin Moller" "the Natural Philosopher", and
I think we only replied to each other in comp.lang.php and here.
I always posted under my real name as far as I can remember.
Maybe you had a different nick some years ago?

I used to be active in java newsgroups.
Or maybe talk.origins where I used to spread my atheistic gospel. ;-)

Regards,
Erwin Moller
 
Ad

Advertisements

T

The Natural Philosopher

Erwin said:
The Natural Philosopher wrote:

My name? Your name rings a bell too, but that could very well be because
you write in c.l.javascript or c.l.php.
I googled in groups with: "Erwin Moller" "the Natural Philosopher", and
I think we only replied to each other in comp.lang.php and here.
I always posted under my real name as far as I can remember.
Maybe you had a different nick some years ago?

I used to be active in java newsgroups.
Or maybe talk.origins where I used to spread my atheistic gospel. ;-)
It was definitely in atheistic contexts, but not talk.origins.

This usenet ID is not that old. Earlier ones got spammed out and were
abandoned.

I won't reveal what they were. Not publically anyway ;-)

Anyway, hi, and enjoyed them enough to remember the name anyway..;-)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top