Are you a Google Analytics enthusiast?
Share and download Custom Google Analytics Reports, dashboards and advanced segments--for FREE!

www.CustomReportSharing.com
From the folks who brought you High Rankings!
More SEO Content
Inserting A Value Into A Form, Help
#1
Posted 07 December 2004 - 03:08 PM
Hello ,
I am looking for a cgi script that will automatically insert a value into a text input field, when a link is clicked
The scenario:
we sell machines, and costumers have the option of requesting a quote, I would like to have the model # of the machine automatically inserted into the quote when the costumer clicks the "request a quote" link.
thanks
#2
Posted 07 December 2004 - 04:27 PM
#3
Posted 08 December 2004 - 11:44 AM
FreeBSD operating system, version 4.8-STABLE.
Apache is used and has the following modules installed:
mod_env
mod_php
mod_setclass
mod_log_config
mod_mime
mod_negotiation
mod_status
mod_include
mod_autoindex
mod_dir
mod_cgi
mod_asis
mod_imap
mod_actions
mod_userdir
mod_alias
mod_rewrite
mod_access
mod_auth
mod_frontpage
mod_auth_anon
mod_auth_dbm
mod_digest
mod_expires
mod_headers
mod_unique_id
mod_setenvif
Is that what you were looking for?
Links to tutorials or script would also help, thanks.
#4
Posted 08 December 2004 - 12:04 PM
Then the request_quote.php would return a html file with this in it:
Don't know if a script is available for this, but it shouldn't be that difficult with some PHP knowledge or a good book.
HTH - Renegade.
#5
Posted 08 December 2004 - 01:28 PM
<input type="text" name="moo" />
</form>
<script language="javascript">
function populateField(form, field, str){
document[form][field].value = str;
}
</script>
<a href="javascript: populateField('myform', 'moo', 'Some value')">Click</a>
Just pass the formname, field, and a string to the populateField function via the a href and jobs a good'n. You could also call the function via the onmouseup event.
You could mix this with PHP to get the variable from the query string or write a bit of JS to parse it... or do it all in PHP even - but then you would have to make the page refresh methinks.
Cheers
LiLo
#6
Posted 08 December 2004 - 03:37 PM
Pardon me if you have already said this but if you wanted to pass the "some value" to a form on a different page of your website, how would you do that ?
#7
Posted 09 December 2004 - 03:32 AM
www.yourwebsite.com?var=someval&var2=anotherval
You can get the args from the querystring (the variables) by using a function like this:
var args = new Object;
var query = location.search.substring(1);
var pairs = query.split("&");
for(var i=0; i<pairs.length; ++i) {
var pos = pairs[i].indexOf('=');
if(pos == -1) continue;
var argname = pairs[i].substring(0, pos);
var value = pairs[i].substring(pos + 1);
args[argname] = unescape(value);
}
return args;
}
//then get the variables like this:
querystring = getArgs();
alert (querystring.var);
Then you would set the form like I said in the last post...
Personally I would use PHP rather than Javascript, but it depends what you have got available on your server - Javascript pretty much everyone can use.
LiLo
#8
Posted 09 December 2004 - 03:52 AM
Product link:
And in quote_request.php:
$m = trim($_GET['m']);
?>
<input type ="text" id="m" value="<?php $m; ?>" />
#9
Posted 09 December 2004 - 03:59 AM
Couldnt agree more
#10
Posted 09 December 2004 - 02:33 PM
but I can't get the "1234" to show up in the text field when I click on the link
what am I doing wrong?
#11
Posted 10 December 2004 - 08:08 AM
Instead of this:
$m = trim($_GET['m']);
?>
<input type ="text" id="m" value="<?php $m; ?>" />
Try this:
$m = trim($_GET['m']);
?>
<input type ="text" id="m" value="<?php echo $m; ?>" />
#12
Posted 10 December 2004 - 08:40 AM
Instead of this:
$m = trim($_GET['m']);
?>
<input type ="text" id="m" value="<?php $m; ?>" />
Try this:
$m = trim($_GET['m']);
?>
<input type ="text" id="m" value="<?php echo $m; ?>" />
Ouch, good spot Randy. Sorry heyman. Next time I'll actually look at what I'm typing
#13
Posted 10 December 2004 - 09:22 AM
Practice makes perfect they say. Doesn't keep me from mucking things up on a daily (hourly?) basis, but I have gotten much better at spotting stuff.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users








