corychauvin
Programmer
Hello,
I need to be able to hard-code a url link that goes to a form page which populates 2 text box's in the form.'
Link would be something like:
this would go to a Quote page with a form and we need the Make and Model textbox's to be filled in from the values of the querystring.
I can get the receiving page to write the values to the page but i can't get the values into the textbox's???. Normally, i use php but for this particular project was done using .shtml / .cgi and my javascript is basic at best.
Here is what i'm currently using, maybe someone will be able to see what i'm doing wrong.
---------------------------------------------
<script language="javascript" type="text/javascript">
function obtainValuesPassed()
{
var infoPassed = location.search;
infoPassed = infoPassed.replace(/\+/g," ");
infoPassed = unescape(infoPassed);
infoPassed = infoPassed.replace(/\?/,"");
var dataPairArray = infoPassed.split(/&|=/);
var extractedData = new Array();
for (var arrayIndex = 0; arrayIndex < dataPairArray.length; arrayIndex++)
{
extractedData[dataPairArray[arrayIndex]] = dataPairArray[++arrayIndex]
}
return extractedData;
}
var valuesPassed = obtainValuesPassed();
if(valuesPassed.length > 0 ){
document.form1[0].Make.value = valuesPassed;
}
</script>
<body onload="obtainValuesPassed()">
<form action="" method="get" name="form1">
<input name="Make" type="text" id="Make"/>
<input name="Model" type="text" id="Model" />
</form>
</body>
I need to be able to hard-code a url link that goes to a form page which populates 2 text box's in the form.'
Link would be something like:
this would go to a Quote page with a form and we need the Make and Model textbox's to be filled in from the values of the querystring.
I can get the receiving page to write the values to the page but i can't get the values into the textbox's???. Normally, i use php but for this particular project was done using .shtml / .cgi and my javascript is basic at best.
Here is what i'm currently using, maybe someone will be able to see what i'm doing wrong.
---------------------------------------------
<script language="javascript" type="text/javascript">
function obtainValuesPassed()
{
var infoPassed = location.search;
infoPassed = infoPassed.replace(/\+/g," ");
infoPassed = unescape(infoPassed);
infoPassed = infoPassed.replace(/\?/,"");
var dataPairArray = infoPassed.split(/&|=/);
var extractedData = new Array();
for (var arrayIndex = 0; arrayIndex < dataPairArray.length; arrayIndex++)
{
extractedData[dataPairArray[arrayIndex]] = dataPairArray[++arrayIndex]
}
return extractedData;
}
var valuesPassed = obtainValuesPassed();
if(valuesPassed.length > 0 ){
document.form1[0].Make.value = valuesPassed;
}
</script>
<body onload="obtainValuesPassed()">
<form action="" method="get" name="form1">
<input name="Make" type="text" id="Make"/>
<input name="Model" type="text" id="Model" />
</form>
</body>