Hello,

I have a problem that I'm trying to figure out. I'm trying to come up with a solution where I have multiple links in a form...

Let me give an example :

<form name='newForm' method='post' action=''>


while($row .....) {
<input type='hidden' value='".$id."' name='selBillAdd'/>
<a href='#' onclick='document.forms["newForm"].submit();' >Use This Address</a>
}

<a href='#' onclick='document.forms["newForm"].submit();' >Use This Address</a>

</form>

*note: I know I don't have the correct syntax, but I'm just showing a simplified version to make the code easier to read.


So I have set up a while loop and inside are links. and it corresponds with a set of different data the user can choose.

Now the user has the option to choose the already address that is in the database, or the user can choose to input new address which is the link that I have outside of the while loop.

How do I set up a system where if the user inputs data, my page won't select any of the other links?

Is there a way to set each link as a POST value? so when they click on that specific link, i can set a

if(isset($_POST...

function?

Thank you!

Recommended Answers

All 2 Replies

check this:

<?php 
$dblink="test1.php";
if($_POST['link']=="old")
echo $_POST['finalLink'];
else
echo $_POST['finalLink'];
?>
<head>
<script type="text/javascript">
function clickRadio()
{
	if(newForm.link[0].checked==true)
	{
		newForm.newLink.value="";
		newForm.newLink.disabled =true;
	}
	else if(newForm.link[1].checked==true)
	{
		newForm.newLink.disabled =false;
		newForm.newLink.focus();
	}
}
function validate()
{
	if(newForm.link[0].checked==true)
		newForm.finalLink.value=newForm.oldLink.value;
	else if(newForm.link[1].checked==true)
		newForm.finalLink.value=newForm.newLink.value;
	alert(newForm.finalLink.value);
}
</script>

</head>
<BODY >
<br>
<br>
<form name='newForm' method='post' action=''>

<Input type = 'Radio' Name ='link' value= 'old' onClick="clickRadio();">Old
<input type="hidden" name="oldLink" value="<?php echo $dblink;?>">
<Input type = 'Radio' Name ='link' value= 'new' onClick="clickRadio();">New
<input type="text" name="newLink" value="">

<input type="hidden" name="finalLink" value="">
<br>
<br>
<input type="submit" name="submit" value="Submit" onclick="validate();">
</form>

</BODY>
</HTML>

Thank you for responding. This script looks a little complicated. Is there an easier way? I'll try to understand this regardless.

Thank you!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.