Jump to content

3 buttons and a FORM, how to make url+value of INPUT type="text"?


phpuse

Recommended Posts

There is a FORM, INPUT type="text". And there are three buttons. Kindly ask you to help with this: after you put some info to the form, you push one button and you go to one URL. If you push another button, you go to different URL. And if you push the third button you go to the third different URL. But the info for this goto is taken from the INPUT type="text" form. It is 5-7 figures that are added to the URL after "?". It looks like that:  www.somesite.com/archive.php?ndx= and here is the info from the form (1234567, like this)

Could you show your code so we have some idea of what you're talking about?

 

I made it this way, using onClick

<form action="" target="_blank">
<input type="text" id="index" name="index" maxlength="10" size="10" style="font-size:25; text-align:center">

<input class="btns" type="button" id="rekl" name="rekl" value="Adds"
		onClick="location.href='http://www.somesite/adds.php?id='+document.getElementById('index').value";>
<input class="btns" type="button" id="art" name="art" value="Articls"
		onClick="location.href='http://www.somesite/artcls.php?id='+document.getElementById('index').value";>
<input class="btns" type="button" id="pics" name="pics" value="Photos"
		onClick="location.href='http://www.somesite/pics.php?id='+document.getElementById('index').value";>

 

And it works correctly, but I'd lke to make it using php and don't know how.

Oh, I see what you're saying now ...

 

Pretty easy,

 

(pseudo code)

if (isset($_post['ads']))

{

$id=$_POST['ID'];

header('Location: http://www.somesite.com/ads.php?id=".$id."');

}

ELSE

if (isset($_post['articles .... etc

 

}

ELSE

{

 

form, method = post, action = php self

input txt name ID

submit1 name=ads

submit2 name=articles

submit3 name=photos

 

}

 

Something like that would work fine ... I'm sure there's an even easier way as well, but that's how I'd do it.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.