...

View Full Version : I want to use data from an input to create a URL



outdoorxtreme1
11-02-2006, 04:21 PM
Can anyone help me with this code? I would like to take the data entered from this string:

<input type="text" size=40 maxlength=40 name="saddr" id="saddr" value="" />

and the data from this line:

<input type="hidden" name="daddr" value="40.00000, -80.00000"/>

and insert it into this :

onClick="fullScreen(\'http://maps.google.com/maps?saddr=\')"

so that the link would be something like this:

http://maps.google.com/maps?saddr=41.00000,-81.00000daddr=40.00000,-80.00000

The whole code I am working on is below


echo "<script language=\"Javascript\">
<!--
var str = \"left=0,screenX=0,top=0,screenY=0\";
if (window.screen){
var ah = screen.availHeight - 30;
var aw = screen.availWidth - 10;
str += \",height=\" + ah;
str += \",innerHeight=\" + ah;
str += \",width=\" + aw;
str += \",innerWidth=\" + aw;
} else {
str += \",resizable\";
}
function fullScreen(theURL) {
return window.open(theURL, '', str);
}
//-->
</script>";
echo '<form name="addr_form" id="addr_form" onSubmit="fullScreen(); return false;">
<b>Get Directions</b>
<br>
<font size=2>Your address: (street, town, state)</font><br>
<input type="text" size=40 maxlength=40 name="saddr" id="saddr" value="" />
<input type="button" type="submit" onClick="fullScreen(\'http://maps.google.com/maps?saddr=&daddr=\')" value="Go">
<input type="hidden" name="daddr" value="40.00000,-80.00000"/>
</form>';

outdoorxtreme1
11-02-2006, 05:17 PM
I want to something like this but I think I am missing something.


echo "<script language=\"Javascript\">
<!--
var str = \"left=0,screenX=0,top=0,screenY=0\";
if (window.screen){
var ah = screen.availHeight - 30;
var aw = screen.availWidth - 10;
str += \",height=\" + ah;
str += \",innerHeight=\" + ah;
str += \",width=\" + aw;
str += \",innerWidth=\" + aw;
} else {
str += \",resizable\";
}
function fullScreen(theURL) {
return window.open(theURL, '', str);
}
var InfoHTML = '<form name=\"addr_form\" id=\"addr_form\" onSubmit=\"fullScreen(\'http://maps.google.com/maps?saddr='+saddr+'\'); return false;\"><b>Get Directions</b><br><font size=2>Your address: (street, town, state)</font><br><input type=\"text\" size=40 maxlength=40 name=\"saddr\" id=\"saddr\" value=\"\" /><input type=\"button\" type=\"submit\" onClick=\"fullScreen(\'http://maps.google.com/maps?saddr='+saddr+'\')\" value=\"Go\"><input type=\"hidden\" name=\"daddr\" value=\"40.00000, -80.00000\"/></form>'
document.write(InfoHTML);
var saddr=document.getElementById('saddr').value;
var daddr=document.getElementById('daddr').value;
//-->
</script>";

VortexCortex
11-02-2006, 10:25 PM
I don't have time to modify your code, but from the first example elements you could use this:

onClick="fullScreen(\'http://maps.google.com/maps?saddr=\'+document.getElementById('saddr').value+'&daddr='+document.getElementById('daddr').value)"



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum