/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] I Need Help! (JAVASCRIPT: FRONTPAGE FORMS)

Hello All,
My friend has a web site were she posts sewing patterns for people who want these patterns sewn for them on blankets and such.

Anyway, she asked if I could help her. The problem is this:

When a customer finds the pattern they want and selects it, they then need to open the request form. We need the pattern that they want to auto fill just the PATTERN ID number to the request form once it is selected. The resquest form contains no values when it is opened. [B]What we need is for the form to contain the PATTERN ID NUMBER that was chosen before hitting submit or accept.[/B]

This will then allow the user to fill in the form and not have to worry about going back and trying to locate the PATTERN ID NUMBER and then try to fill it in.

If anyone could help with this as soon as possible, it would be greatly appreciated.

Thanks,

Jarrodmadd

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@Typhoon101Dec 12.2006 — For this example you need 2 pages. page1.htm and page2.htm

[B]page1.htm[/B]
[code=html]<html>
<head>
</head>

<body>
<form id="patterns" method="get" action="page2.htm">
<input type="radio" name="pattern" value="Pattern 1" checked="checked" /> Pattern 1<br />
<input type="radio" name="pattern" value="Pattern 2" /> Pattern 2<br />
<input type="radio" name="pattern" value="Pattern 3" /> Pattern 3<br />
<input type="radio" name="pattern" value="Pattern 4" /> Pattern 4<br />
<input type="radio" name="pattern" value="Pattern 5" /> Pattern 5<br />
<input type="radio" name="pattern" value="Pattern 6" /> Pattern 6<br />
<input type="radio" name="pattern" value="Pattern 7" /> Pattern 7<br />
<input type="submit" value="submit" />
</form>
</body>
[/code]


[B]page2.htm[/B]
[code=html]<html>
<head>
<script type="text/javascript">
function getQueryVariable(variable) {
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
if (pair[0] == variable) {
pair = pair[1].replace('+', ' ')
return pair;
}
}
alert('Query Variable ' + variable + ' not found');
}

window.onload=function(){
document.getElementById('pattern').value = getQueryVariable("pattern");
}
</script>



</head>

<body>
<form id="orderForm" action="somepage.htm" method="post">
<input type="text" id="pattern" value="" />
</form>
</body>
[/code]


Then load page1.htm in your browser and fill out the form. On the resulting page, the pattern field should be populated with the pattern number.
Copy linkTweet thisAlerts:
@jarrodmaddauthorDec 12.2006 — Thanks. I will give it a try.
×

Success!

Help @jarrodmadd spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...