Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A little challenge

Status
Not open for further replies.

macmonteiro

Programmer
Oct 24, 2002
35
BR
Hullo, guys.
I'm really sorry it's about variables again. This time the question was set by a friend of mine and it raised my curiosity.
This code is just alright...
------------------------------------------------
<a href=&quot;page2.php?variable1=value1&variable2=value2&variable3=value3&quot;>Next page</a>
-------------------------------------------------
But what if someone wanted to write just the variable name in the URL. Say, inside a function.
Is there any code to come previously that could make it happen?
It's kind of a theoric question, so follow your imagination.
Bye
-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
 
Is this what you are asking?

<a href=&quot;javascript: goThere()&quot;>Next Page</a>
<script>
function goThere(){
value1 = &quot;one&quot;
value2 = 2
value3 = &quot;three&quot;
document.location = &quot;page2.php?variable1=&quot;+value1+&quot;&variable2=&quot;+value2+&quot;&variable3=&quot;+value3
}
</script>
 
nops
say we had a form where:
cad_nam='mac'
cad_age='23'
cad_val='v'
and we wanted after we validated these data, send 'em to a PHP page called info.php
I'd be alright if instead of:
document.cadastro1.submit()
we wanted:
parent._main.location=&quot;info.php?cad_nam=&quot;+form.cad_nam.value+&quot;&cad_age=&quot;+form.cad_age.value
But is there any way write just the variable name into the URL.
I say it's impossible, stupid and useless but my friend says he's found a way.
Well, I'm kind of a JS-monkey so I may wrong!
 

1. is it that you don't want the user to see the long trail of pairs that follow?

2. what and where are you validating these values against? are you validating that they are the right values, so a true/false test might work, or are you validating that the values follow a certain syntax?

3. or are you asking if a variable can be made for the entire value of all the options, and that one variable with its new value(s) be carried as one word through the url?

- g
 
okay spew, lets go

1) yeah, its kind of that but if this was the problem we'd just use the &quot;post&quot; method ;-)

2) I'm making a lot of different validations. cad_nam can't be a number, cad_email must have the e-mail syntax and so on. But this part is easy and it's done.

3) I'm not trying to carry only one variable. In fact it would be useless for the PHP SQL insertion routina.

The point is that if you send the data using:
parent._main.location=&quot;info.php?cad_nam=&quot;+form.cad_nam.value+&quot;&cad_age=&quot;+form.cad_age.value
and then you wrote into your PHP
<?
echo $cad_nam
?>

it would return
'/cad_nam=marcos/'
just like JS had sent.

The final purpose is that
<?
echo $cad_nam
?>
returns only
marcos

-_--__--__--__--__--__--__--__--__--__--__--__--__--_
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top