A2xA Posted February 2, 2008 Share Posted February 2, 2008 Okay basically the user makes a hub and they type in their "hub id" and it pops up with a window. Well I've got the javascript and everything down but they have to type in /hubfolder/hubname.swf for it to open. I want to combine a hidden field with a normal text field so that it will read like this: <html> <head> <script language="javascript"> function popUp() { day = new Date(); id = day.getTime(); var URL = document.getElementById('urlselection').value; window.open(URL,'' + id + '','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=275,height=300') } </script> </head> <body> <div style="text-align: left;"><a href="http://wiicharged.com/index.php?action=hubs"><img style="border: 0px solid ; width: 656px; height: 125px;" alt="Wii forum friend codes" src="http://i27.tinypic.com/2n24pag.png"></a><br> <br><br> <form onsubmit="popUp(); return false"> <input type="hidden" name="hubid" value="/hubchats/"> <input type="text" id="urlselection"> <input type="hidden" name="hubid2" value="shout.swf"> <input type=button value="Join the hub" onClick="popUp()"> </form> </body> </html> Quote Link to comment Share on other sites More sharing options...
haku Posted February 2, 2008 Share Posted February 2, 2008 Its not very clear what you want, or even what is happening now. Outline your problem in these steps: 1) overall goal of function 2) what the step you are working on now is 3) what you want to happen 4) what is actually happening. Also probably a good idea to actually include a question somewhere. Quote Link to comment Share on other sites More sharing options...
A2xA Posted February 2, 2008 Author Share Posted February 2, 2008 combining two forms? I'm sorry I thought I was clear it's in the title of the thread... also I want to combine a hidden field with a normal text field <form onsubmit="popUp(); return false"> <input type="hidden" name="hubid" value="/hubchats/"> <input type="text" id="urlselection"> <input type="hidden" name="hubid2" value="shout.swf"> <input type=button value="Join the hub" onClick="popUp()"> </form> Quote Link to comment Share on other sites More sharing options...
haku Posted February 2, 2008 Share Posted February 2, 2008 What about combining 2 forms? Are you asking if it can be done? The answer is yes. If you have one form, and you take it and put all the XHTML output in another form, and then you adjust the processing script, it can be done. What do you mean you want to combine a text field and an hidden field? You already have done that - you have text fields and hidden fields on your form. Still not clear on what the problem is here. Quote Link to comment Share on other sites More sharing options...
A2xA Posted February 2, 2008 Author Share Posted February 2, 2008 ... I know I HAVE combined them, the problem is it dosen't work. That was my attempt at combining the fields. I needed to ask how it can be done. How can I combine the two text fields to submit the same information? ie if the hidden field's value is /hubchat/ then the text I put smile so the output would be /hubchat/smile Quote Link to comment Share on other sites More sharing options...
haku Posted February 2, 2008 Share Posted February 2, 2008 On that note, your topic wasn't clear at all. You aren't trying to combine two forms, you are trying to combine two fields. This is why the more detailed your explanation is, the easier it is to answer. The answer to your problem is easy, understanding what you were talking about was the difficult part. Try the four step process I outlined in your future inquiries. You don't even need the hidden fields. In your processing script, just do this: <?php $path = "/hubchat/" . $_POST['urlselection']; ?> $path will then be equal to whatever /hubcat/_____ where the blank filled in with whatever you put into your <input type="text"> tag. You have to fix that tag though, as it wont work the way it is now. It should look like this: <input type="text" name="urlselection" id="urlselection" /> Quote Link to comment Share on other sites More sharing options...
A2xA Posted February 2, 2008 Author Share Posted February 2, 2008 The problem is it is staying on the same page. I'm using javascript to make a popup window. There is no processing script. And my bad about saying forms. I meant fields Quote Link to comment Share on other sites More sharing options...
A2xA Posted February 2, 2008 Author Share Posted February 2, 2008 here is where the place is, if you want to see what I'm trying to accomplish http://wiicharged.com/index.php?action=hubs;sa=join; Quote Link to comment Share on other sites More sharing options...
haku Posted February 2, 2008 Share Posted February 2, 2008 Then your problem is javascript related, and not PHP at all, which means you are asking in the wrong place altogether. But, since you asked, you can still accomplish this without setting the hidden fields. Set up your javascript to look like this: var textInput = document.getElementById("urlselection").value var path = "/hubchat/" + textInput[code] The path is now in your javascript variable of textInput. [/code] Quote Link to comment Share on other sites More sharing options...
A2xA Posted February 2, 2008 Author Share Posted February 2, 2008 Okay, I'm sorry I guess I did post this in the wrong section. I've got this now: <html> <head> <script language="javascript"> function popUp() { day = new Date(); id = day.getTime(); var textInput = document.getElementById("urlselection").value var path = "/hubchat/" + textInput[code] + "shout.swf" window.open(URL,'' + id + '','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=275,height=300') } </script> </head> <body> <div style="text-align: left;"><a href="http://wiicharged.com/index.php?action=hubs"><img style="border: 0px solid ; width: 656px; height: 125px;" alt="Wii forum friend codes" src="http://i27.tinypic.com/2n24pag.png"></a><br> <br><br> <h3>Enter your Hub ID you want to join<h3> <form onsubmit="popUp(); return false"> <input type="text" id="urlselection"> <input type=button value="Join the hub" onClick="popUp()"> </form> </body> </html> For some reason the variable isn't defining though and my de-bugging says code is not defined [break on this error] var path = "/hubchat/" + textInput[code[ + "shout.swf" Thanks for the help by the way I really appreciate it.[/code] Quote Link to comment Share on other sites More sharing options...
haku Posted February 2, 2008 Share Posted February 2, 2008 Look at this: var textInput = document.getElementById("urlselection").value var path = "/hubchat/" + [b]textInput[code][/b] + "shout.swf" Why did you add ' ' to textinput? [/code] Quote Link to comment Share on other sites More sharing options...
A2xA Posted February 2, 2008 Author Share Posted February 2, 2008 I didnt... Quote Link to comment Share on other sites More sharing options...
haku Posted February 2, 2008 Share Posted February 2, 2008 Sorry, that outputted wrong. From your code, I think your path should read like this: var path = "/hubchat/" + textInput + "shout.swf" Quote Link to comment Share on other sites More sharing options...
A2xA Posted February 2, 2008 Author Share Posted February 2, 2008 :-X No that still didn't work. I'm pretty sure it's almost right though. Are you sure javascript can simultaneously define to variables and popup the window? <html> <head> <script language="javascript"> function popUp() { day = new Date(); id = day.getTime(); var textInput = document.getElementById("urlselection").value var path = "/hubchat/" + textInput + "shout.swf" window.open(URL,'' + id + '','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=275,height=300') } </script> </head> <body> <div style="text-align: left;"><a href="http://wiicharged.com/index.php?action=hubs"><img style="border: 0px solid ; width: 656px; height: 125px;" alt="Wii forum friend codes" src="http://i27.tinypic.com/2n24pag.png"></a><br> <br><br> <h3>Enter your Hub ID you want to join<h3> <form onsubmit="popUp(); return false"> <input type="text" id="urlselection"> <input type=button value="Join the hub" onClick="popUp()"> </form> </body> </html> Quote Link to comment Share on other sites More sharing options...
haku Posted February 2, 2008 Share Posted February 2, 2008 It can. You are just constructing the URL, then using it. You say that your code doesn't work - what do you mean. What are you trying to do, what's it supposed to be doing, and what is actually happening? Quote Link to comment Share on other sites More sharing options...
A2xA Posted February 2, 2008 Author Share Posted February 2, 2008 Well, when I enter in the code nothing pops up. I get an error from my debugging that says URL is not defined [break on this error] window.open(URL,'' + id + '','toolbar=0,scrollbars=0,location=0,statusbar=0,menu... I'm trying to get it to pop up with my chat window that will popup when the variable is filled. What's hapenning is that supposedly the url is not defining itself. Maybe a syntax error in defining the textInput Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted February 2, 2008 Share Posted February 2, 2008 On this line: window.open(URL,'' + id + '','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=275,height=300') you do not have a variable URL, you need to define one, and the page to be opened. Quote Link to comment Share on other sites More sharing options...
A2xA Posted February 2, 2008 Author Share Posted February 2, 2008 thanks to both of you it's working, I appreciate it! haku you were right just I didn't define the url as little guy was saying instead of var path i put var URL var textInput = document.getElementById("urlselection").value var URL = "/hubchats/" + textInput + "/shout.swf" window.open(URL,'' + id + '','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=275,height=300') } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.