Click to See Complete Forum and Search --> : form, dropdown list, array - populate links properly


mr_fitz
05-05-2003, 01:26 PM
I have a form that includes a dropdown list of links that are to be populated from a mysql database.

The following code will produce:

http://www.google.ca/?member_link=http%3A%2F%2Fwww.google.ca
if www.google.ca (http://www.google.ca ) is in the mysql database for $member_link

<form name="member_links" target="_blank" method="GET" onsubmit="this.action=member_link[member_link.selectedIndex].value">
<select name="member_link">
<?php
$SQL = "SELECT * FROM member_links WHERE Name = '$membername' ORDER BY Link_Label ASC";
$result = mysql_query($SQL);
while ($myrow=mysql_fetch_array($result)) {
$member_link = $myrow["Link"];
$link_label = $myrow["Link_Label"];
$name = $myrow["Name"];
?>
<option value="<?php echo ('http://'. $member_link); ?>"><?php echo $link_label; ?></option>
<?php
}//end while
?>
</select>
<input type="submit" value="Go">
</form>


QUESTION IN A NUTSHELL:
How do I get rid of the:
?member_link=http%3A%2F%2Fwww.google.ca
part of each link in the drop down menu?

I realize I have redundant code here, I know so very little about javascript and forms - I have been trying different variations for hours and cannot get anything to work.

Jona
05-05-2003, 02:32 PM
<html><head>
<script>
var loc = location.href;
var start = loc.indexOf("?");
var end = loc.length;
if(start){
var final_url = loc.substring(start, end);
location.href = final_url.split(final_url).join("");
}
alert(final_url);
</script>
</head><body>

<a href="?test=ing&blah=foo">Test</a>

</body></html>

This script clears the ? and everything after it in the URL.

mr_fitz
05-05-2003, 03:43 PM
unfortunately, because this is in the header, it messes up other forms/links on the same page.

mr_fitz
05-05-2003, 05:49 PM
Is there anyway to stop all the stuff after the ? in the form itself?

Is there a way to implement code similar to Jona's that does not affect any other links on the page - i.e., not in the header?

I am not a javascripter, can you tell?
thanks for any thoughts.

Jona
05-05-2003, 06:48 PM
Originally posted by mr_fitz
Is there anyway to stop all the stuff after the ? in the form itself?

Try using the method="POST" in your form.

mr_fitz
05-05-2003, 07:26 PM
POST won't work because many apache servers are set up NOT to accept POSTS from other sites. I originally was using the POST method, but continued to get the error on most sites.

more details here:
http://forums.devshed.com/t60451/s.html

I thought this would all be so simple...

Any others?