| | |
Pre-fill automatically a form field with part of the URL
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Aug 2009
Posts: 5
Reputation:
Solved Threads: 0
Hello,
I am developing a site with Dreamweaver CS3 and have a little knowledge of HTML.
I need a solution for the following:
Visitors can come to my site through a referrer for ex: www.domain.com/?ref=cesar017
The referrer’s information (cesar017) should be prefilled automatically in a form field on another page than the index page. This means the visitor first can look around on the other pages of the site and then go to the page with the form. I don’t use a database at this moment, I only want a certain field automatically prefilled with the referrer’s info from the URL for ex : <input type= hidden -or text- name= partner id= partner value= ""/> In this case the field should have the value=”cesar017”
I understood this can be solved with Javascript or PHP and cookies, but I nearly don’t know anything about this and Dreamweaver has not automated this function.
Can somebody help me with this script (how, where * head - body section *…)
In advance thanks for your help
I am developing a site with Dreamweaver CS3 and have a little knowledge of HTML.
I need a solution for the following:
Visitors can come to my site through a referrer for ex: www.domain.com/?ref=cesar017
The referrer’s information (cesar017) should be prefilled automatically in a form field on another page than the index page. This means the visitor first can look around on the other pages of the site and then go to the page with the form. I don’t use a database at this moment, I only want a certain field automatically prefilled with the referrer’s info from the URL for ex : <input type= hidden -or text- name= partner id= partner value= ""/> In this case the field should have the value=”cesar017”
I understood this can be solved with Javascript or PHP and cookies, but I nearly don’t know anything about this and Dreamweaver has not automated this function.
Can somebody help me with this script (how, where * head - body section *…)
In advance thanks for your help
Belper,
It's probably best to get index page to set a session variable. By doing so the referer value will be available to other web pages during the same user session.
I'm not a Dreamweaver person but you could try Googling "Dreamweaver session variables" or similar.
Alternatively, you could set a cookie which provides longer term storage of data, but it is stored client-side, not server-side.
For this try Googling "Dreamweaver cookies" or similar.
Airshow
It's probably best to get index page to set a session variable. By doing so the referer value will be available to other web pages during the same user session.
I'm not a Dreamweaver person but you could try Googling "Dreamweaver session variables" or similar.
Alternatively, you could set a cookie which provides longer term storage of data, but it is stored client-side, not server-side.
For this try Googling "Dreamweaver cookies" or similar.
Airshow
50% of the solution lies in accurately describing the problem!
•
•
Join Date: Aug 2009
Posts: 5
Reputation:
Solved Threads: 0
0
#3 Oct 28th, 2009
Hello,
First of all my apologies for the delay in my replay (I have been unable to post these last months for personal reasons. Thanks for understanding).
This is the solution that is working and is the best one for my needs :
Add this anywhere before your HTML begins to start the cookie.
PHP Code:
cookie will remain on client-side for 1 hour. If you want to store the cookie for a longer period on client-side
time()+60*60*24*30 is seconds*minits*hours*days
if time is O or not mentioned, than the cookie will be canceled at the end of the session
Then use the cookie on your page with the form field :
Thanks to all the people that helped me.
First of all my apologies for the delay in my replay (I have been unable to post these last months for personal reasons. Thanks for understanding).
This is the solution that is working and is the best one for my needs :
Add this anywhere before your HTML begins to start the cookie.
PHP Code:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<?php if(isset($_GET['ref'])) setcookie('referrer', $_GET['ref'], time()+3600); ?>
time()+60*60*24*30 is seconds*minits*hours*days
if time is O or not mentioned, than the cookie will be canceled at the end of the session
Then use the cookie on your page with the form field :
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<input type="text" name="referrer" value="<?php echo htmlspecialchars($_COOKIE['referrer']); ?>" />
![]() |
Similar Threads
- Msql. Insert data depending on which form field is filled out. (PHP)
- Pre-Fill Subject and Body fields in Web Outlook (JavaScript / DHTML / AJAX)
- javascript variale does not pass in url please help me to find out the solution (JavaScript / DHTML / AJAX)
- Web browser with predermined par of URL (VB.NET)
- results to form field (PHP)
- Auto fill in Access form (MS Access and FileMaker Pro)
- Product List and Order Form Submit (JavaScript / DHTML / AJAX)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Make AJAX degradable
- Next Thread: Portability
| Thread Tools | Search this Thread |
Tag cloud for JavaScript / DHTML / AJAX
ajax ajaxexample ajaxjspservlets array autoplay blackjack browser captchaformproblem checkbox child class close codes date debugger dependent developer disablefirebug dom editor element embed engine events explorer ext file firefox flash form forms game getselection google gxt hiddenvalue highlightedword hint html ie7 ie8 iframe internet java javascript javascripthelp2020 jquery jsf jsfile jsp jump libcurl maps marquee masterpage math matrixcaptcha media mysql object onerror onmouseoutdivproblem onreadystatechange parent passing paypal pdf php player position post programming rated redirect runtime safari scale scriptlets scroll search security session shopping size software sources star stars stretch synchronous toggle tweet unicode variables web webkit webservice window wysiwyg \n





