Jump to content

[SOLVED] combining 2 forms?


A2xA

Recommended Posts

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>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

...

 

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

Link to comment
Share on other sites

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" />

Link to comment
Share on other sites

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]

Link to comment
Share on other sites

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]

Link to comment
Share on other sites

:-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>

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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')
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.