DanH42 Posted August 11, 2009 Share Posted August 11, 2009 I'm trying to make a page that will use a user-submitted input as a variable in a <div>. something like:<input type="text" name="textfield"><input name="subj" type="submit" id="subj" value="Submit"><br><div class="monitter" id="tweets" title=subj lang="en"></div>Where subj is the variable that i want to be changed when the form is submitted.Not sure if this is possible with purely HTML or not.I don't mind if the page has to redirect somewhere else, although a non-redirecting solution would be nice. Link to comment Share on other sites More sharing options...
Guest FirefoxRocks Posted August 11, 2009 Share Posted August 11, 2009 Redirecting requires PHP, and is more accessible than non-redirecting. Well, it could be done with ASP and other S3L, but I don't know any .Non-redirecting requires JavaScript and doesn't work if users have JavaScript disabled.Redirecting method:Page 1: <form action="page2.php" method="get"><p><input type="text" name="textfield"> <input type="submit" id="subj" value="Submit"></p></form> Page 2: <!DOCTYPE html><html><head><title>Page 2 </title></head><body><?php if(isset($_GET["textfield"]) && !empty($_GET["textfield"])) { $x = $_GET["textfield"]; }?> ... some HTML here ...<!-- remove the form if you wish --><form action="page2.php" method="get"><p><input type="text" name="textfield"> <input type="submit" id="<?php echo $x; ?>" value="Submit"></p></form><div class="monitter" id="tweets" title="<?php echo $x; ?>" lang="en"></div>... some more HTML here perhaps? ...</body></html> Non-redirecting (however I will omit the ID attribute from the submit button because I'm not sure if you need it): <!DOCTYPE html><html><head><title>Page 2 </title><script type="text/javascript">function changeTitle(text){ document.getElementById("tweets").title = text;}</script></head><body><!-- ... some HTML here ... --><p><input type="text" name="textfield"> <input type="submit" value="Submit" onkeyup="changeTitle(this.value);"></p><div class="monitter" id="tweets" lang="en"></div><!-- ... some more HTML here perhaps? ... --></body></html> Hope this helps. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.